fixes a performance problem in one SELECT
Merge pull request #2 from urgrips/master

fixes a performance problem in one sql select