Skip to content
Snippets Groups Projects

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

Merged Dan Notestein requested to merge dn_index_optimizations into develop
Compare and Show latest version
8 files
+ 354
292
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -10,7 +10,19 @@ DECLARE
BEGIN
__account_id = find_account_id( _account, True );
__post_id = find_comment_id( _author, _permlink, True );
RETURN QUERY SELECT
RETURN QUERY
WITH ds AS --bridge_get_account_posts_by_comments
(
SELECT hp1.id
FROM hive_posts hp1
WHERE hp1.author_id = __account_id
AND hp1.counter_deleted = 0
AND hp1.depth > 0
AND (__post_id = 0 OR hp1.id < __post_id)
ORDER BY hp1.id DESC
LIMIT _limit
)
SELECT
hp.id,
hp.author,
hp.parent_author,
@@ -49,16 +61,9 @@ BEGIN
hp.curator_payout_value,
hp.is_muted,
NULL
FROM
(
SELECT hp1.id
FROM hive_posts hp1
WHERE hp1.author_id = __account_id AND hp1.counter_deleted = 0 AND hp1.depth > 0 AND ( __post_id = 0 OR hp1.id < __post_id )
ORDER BY hp1.id DESC
LIMIT _limit
) ds,
FROM ds,
LATERAL get_post_view_by_id(ds.id) hp
ORDER BY hp.id DESC
ORDER BY ds.id DESC
LIMIT _limit;
END
$function$
Loading