speed up contests sql queries