Commit 62ce71e3 authored by Dan Notestein's avatar Dan Notestein
Browse files

[DLN] Add get_post_view_by_id to replace hive_post_view which has too long of...

[DLN] Add get_post_view_by_id to replace hive_post_view which has too long of a planning time. All the joins in hive_post_view are essentially one-to-one (no hive_posts get filtered out by the joins) so order was never super critical within the view itself. But the filtering of hive_posts based on id is critical to performance and needs to be done before any of the joins. I tried to do this without using a function, but wasn't able to figure out how, so ultimately I went created the get_post_view_by_id function and set the join_collapse_limit locally within the function to 1 (locallly settable value was another benefit of using a function). Since functions can't take a table as input, I just pass in the id of a single post. It's possible performance could be increased by passing in an array of ids when there's a lot of ids, but I didn't bother to experiment with this since generally we never process more than about 2000 hive_post ids anyways. I also haven't experimented much with reordering of the manually set joins within get_post_view_by_id, I just chose an order than seemed logical and performance appears good enough so far. Other sql code that joins to hive_post_view should probably also be later be changed to use this function instead and probably remove hive_post_view in favor of a composite type definition, but for now I just changed the usages that were trivally easy to replace. The trivial edits haven't been compiled/tested, so likely to fail in CI.
parent 57d775c5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment