Added indexes and removed 1=1 from queries