Moving check for sharing type first in sql query seems to help databases avoid costly subselects if unnecessary. It was quite bad on performance when adding new sprints. (see #931 and #938)