Slow SQL query causes homepage to load in 2-4 sec

It sort of helped, after this patch the load times are 1-2 secs on average (instead of 4-8 secs before).

Thank you! :smiley: