Skip to content

Query speedups (index optimizations + replacing hive_posts_view to speedup query planning)

Dan Notestein requested to merge dn_index_optimizations into develop

We don't care about deleted replies, so just exclude counter_deleted != 0 from index to make it smaller (2 fields instead of 3). This is for further optimizing of bridge_get_account_posts_by_replies.

Query planning for hive_posts_view takes too long because it has many joins, but mostly the order of these joins isn't very important since they are simple 1-1 joins that don't filter the number of rows or add a lot of data, so replacing it with new get_post_view_by_id function which forces the join order to eliminate the planning time.

There's still a few usages of hive_posts_view in python code (and even a few in SQL files) that can be replaced later.

There's a lot of changes to queries in this commit, so it's possible that existing tests won't detect all problems from this commit...

Note: need to look into PARALLEL and see if this is something we can safely be adding to many of our functions.

Edited by Dan Notestein

Merge request reports