Skip to content
Snippets Groups Projects
Commit 23f96f8f authored by Gandalf's avatar Gandalf Committed by Jason Salyers
Browse files

[JES] Update to the get discussion query. Do the filtering in the sub query to...

[JES] Update to the get discussion query. Do the filtering in the sub query to increase performance, drop an uneeded join for the same reason. Add a limit of 4000 to prevent a huge amount of data being returned (test post that showcased this problem was a post with over 450k children)
parent 83dae9dd
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,10 @@ async def get_discussion(context, author, permlink, observer=None):
sql = """
---get_discussion
WITH RECURSIVE child_posts AS (
SELECT id, parent_id FROM hive_posts WHERE author = :author AND permlink = :permlink
UNION
SELECT id, parent_id FROM hive_posts WHERE author = :author AND permlink = :permlink AND NOT is_deleted AND NOT is_muted
UNION ALL
SELECT children.id, children.parent_id FROM hive_posts children JOIN child_posts ON (children.parent_id = child_posts.id)
WHERE NOT children.is_deleted AND NOT children.is_muted
)
SELECT child_posts.id, child_posts.parent_id, hive_posts_cache.post_id, hive_posts_cache.author, hive_posts_cache.permlink,
hive_posts_cache.title, hive_posts_cache.body, hive_posts_cache.category, hive_posts_cache.depth,
......@@ -39,9 +40,7 @@ async def get_discussion(context, author, permlink, observer=None):
hive_posts_cache.total_votes AS total_votes, hive_posts_cache.flag_weight AS flag_weight,
hive_posts_cache.sc_trend AS sc_trend, hive_accounts.id AS acct_author_id
FROM child_posts JOIN hive_posts_cache ON (child_posts.id = hive_posts_cache.post_id)
JOIN hive_posts ON (hive_posts_cache.post_id = hive_posts.id)
JOIN hive_accounts ON (hive_posts_cache.author = hive_accounts.name)
WHERE NOT hive_posts.is_deleted AND NOT hive_posts.is_muted
"""
blacklists_for_user = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment