I just ran the same basic test query in a copy of our production system, basically doing what bshum did, though I grabbed a known record ID from our system first. I did more than just current master vs my proposed fix, though.
For one thing, we need to not just examine left vs inner join in record_attr_flat, but also the impact of changing record_attr to check for nulls.
Current master with left joins and no null attr check:
Runtime of 1.183 ms
Remove left joins:
Runtime of 1.109 ms
Left joins put back, but with record_attr null check included:
Runtime of 1.110 ms
Both solutions at the same time:
Runtime of 1.133 ms
Given that I got comparable results on both solutions I don't see how either is "better" - especially as every use of record_attr_flat I can find outside of the record_attr view itself is checking against a non-null attr in some way as it is.
I just ran the same basic test query in a copy of our production system, basically doing what bshum did, though I grabbed a known record ID from our system first. I did more than just current master vs my proposed fix, though.
For one thing, we need to not just examine left vs inner join in record_attr_flat, but also the impact of changing record_attr to check for nulls.
Full explain output is available here: http:// pastebin. com/Nciebnsf
A summary, however:
Current master with left joins and no null attr check:
Runtime of 1.183 ms
Remove left joins:
Runtime of 1.109 ms
Left joins put back, but with record_attr null check included:
Runtime of 1.110 ms
Both solutions at the same time:
Runtime of 1.133 ms
Given that I got comparable results on both solutions I don't see how either is "better" - especially as every use of record_attr_flat I can find outside of the record_attr view itself is checking against a non-null attr in some way as it is.