mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
PG9 doesn't like the query from _load_link_comments in comment_tree.py. thing.py will automatically filter deleted and spam items out of thing queries if no rules are specified for those columns. To get around this, some queries, including the _load_link_comments one, will specify a rule like _spam == (True, False). This rule was left in the ruleset, despite the fact that it's completely unnecessary from the SQL's standpoint. Its presence then triggered the need of a join against the thing table when only the data table was truly necessary. The query planner in PG9 doesn't like this particular query when it requires a join and will force a full table scan as a result. This patch notes the special case of _spam/_deleted == (True,False) and turns off the default filtering but removes the rules from the query. This saves some WHERE clauses and more importantly removes the need for a JOIN in queries like this one.