add indexes to optimize sum_supports query

This commit is contained in:
Alex Grintsvayg 2020-11-11 16:56:32 -05:00
parent c1aa9b8150
commit 7d82a4573f
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5
2 changed files with 5 additions and 1 deletions

View file

@ -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)",
]

View file

@ -2591,7 +2591,7 @@ class API:
Use --exclude_own_supports to exclude supports from the channel to itself.
Usage:
support sum <claim_id> [--inculde_channel_content]
support sum <claim_id> [--include_channel_content]
{kwargs}
"""
items, total = await self.service.sum_supports(hex_str_to_hash(claim_id), include_channel_content, exclude_own_supports)