perf: optimize slow queries for trending/feed/community APIs#368
Open
perf: optimize slow queries for trending/feed/community APIs#368
Conversation
Based on beta-hivemind-slow-query-analysis.md report: Database Indexes (v26 -> v27): - Add hive_posts_cache_temp_ix6b: depth+sc_trend index for trending queries - Add hive_posts_cache_temp_ix30b: community+depth+sc_trend index for community queries - Add idx_feed_cache_account_created_desc: optimize feed/blog ORDER BY - Add idx_reblogs_post_account: optimize NOT EXISTS subquery Query Optimization: - Replace 'author NOT IN (subquery)' with NOT EXISTS in: - pids_by_community() - pids_by_category() - NOT EXISTS performs better than NOT IN with PostgreSQL Expected improvement: - Trending queries: 281ms -> ~20ms (14x faster) - Feed queries: 30ms -> ~5ms (6x faster) - Community queries: 23ms -> ~3ms (7x faster) - Total CPU: ~13.6% -> ~2%
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on beta-hivemind-slow-query-analysis.md report:
Database Indexes (v26 -> v27):
Query Optimization:
Expected improvement: