re: SQL Weirdness
I suspect that the sub-query in a sub-query may be doing it.
re: SQL Weirdness
@inmysocks is there a reason you're not using JOINs at all?
re: SQL Weirdness
@zatnosk mainly because I am not very good with SQL.
re: SQL Weirdness
re: SQL Weirdness
@inmysocks I skipped the year-check, but otherwise I think it should select the same data based on joining tables together.
The fanciest part is the INNER JOIN that's only used to filter the primary table.
Now that I think of it, that INNER JOIN might explode your result rows... but the other stuff should be faster than multiple subqueries selecting from the same table
re: SQL Weirdness
@zatnosk it went from 15 seconds to 0.006 seconds.
I just have to be careful about the table sizes with the joins.
re: SQL Weirdness
@inmysocks my best tip is to put as many restrictions in the ON clauses as possible - although I'm not 100% on where the optimizations happen best.
re: SQL Weirdness
@zatnosk change 'not very good' to 'really terrible'.
And thank you.
re: SQL Weirdness
of course, now that I look at it, I could just leave out the date selection in the subquery because at the moment I am checking all of the years represented anyway so I don't need to filter them...