Fixes bug 913126 - Rapid betas in search-based systems

Let's try that one more time. 

@selenamarie, r? on the postgres parts? Mainly on the ``util.py`` file, that is where the slow SQL is.