From 7d82a4573fdf5a915ba6f37e435a4de98e95c7e0 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 11 Nov 2020 16:56:32 -0500 Subject: [PATCH] add indexes to optimize sum_supports query --- lbry/db/tables.py | 4 ++++ lbry/service/api.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lbry/db/tables.py b/lbry/db/tables.py index fdc2c9609..5a0fa3bf7 100644 --- a/lbry/db/tables.py +++ b/lbry/db/tables.py @@ -169,6 +169,8 @@ pg_add_txo_constraints_and_indexes = [ "CREATE INDEX txo_reposted_claim_hash ON txo (reposted_claim_hash)" "WHERE reposted_claim_hash IS NOT NULL AND spent_height = 0;", "CREATE INDEX txo_height ON txo (height);", + # used by sum_supports query (at least) + "CREATE INDEX txo_claim_hash ON txo (claim_hash)", ] @@ -269,6 +271,8 @@ pg_add_claim_and_tag_constraints_and_indexes = [ # basic tag indexes "ALTER TABLE tag ADD PRIMARY KEY (claim_hash, tag);", "CREATE INDEX tags ON tag (tag) INCLUDE (claim_hash);", + # used by sum_supports query (at least) + "CREATE INDEX claim_channel_hash ON claim (channel_hash)", ] diff --git a/lbry/service/api.py b/lbry/service/api.py index 46a0b8ee3..9fd803d5c 100644 --- a/lbry/service/api.py +++ b/lbry/service/api.py @@ -2591,7 +2591,7 @@ class API: Use --exclude_own_supports to exclude supports from the channel to itself. Usage: - support sum [--inculde_channel_content] + support sum [--include_channel_content] {kwargs} """ items, total = await self.service.sum_supports(hex_str_to_hash(claim_id), include_channel_content, exclude_own_supports)