Fixed broken SQL optimisation
Merge branch 'develop' of github.com:openeyes/OpenEyes into develop