Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slow local timeline query #11648

Merged
merged 1 commit into from
Aug 24, 2019
Merged

Fix slow local timeline query #11648

merged 1 commit into from
Aug 24, 2019

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Aug 23, 2019

Fix #11643

Before

Limit  (cost=39150.63..39150.68 rows=20 width=396) (actual time=6520.485..6520.489 rows=20 loops=1)
  ->  Sort  (cost=39150.63..39150.84 rows=84 width=396) (actual time=6520.484..6520.486 rows=20 loops=1)
        Sort Key: statuses.id DESC
        Sort Method: top-N heapsort  Memory: 33kB
        ->  Nested Loop Left Join  (cost=0.98..39148.39 rows=84 width=396) (actual time=0.332..6515.107 rows=16240 loops=1)
              Filter: (accounts.silenced_at IS NULL)
              Rows Removed by Filter: 544
              ->  Index Scan using index_statuses_20190820 on statuses  (cost=0.56..38891.15 rows=101 width=396) (actual time=0.326..6476.242 rows=16784 loops=1)
                    Index Cond: (visibility = 0)
                    Filter: ((local OR (uri IS NULL)) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)) AND (account_id <> ALL ('{61919,125171,111310,77076,100948,103833,1633,1181,505,19662,7254,12537,12749,884,3033,645}'::bigint[])))
                    Rows Removed by Filter: 7290950
              ->  Index Scan using index_accounts_on_id on accounts  (cost=0.42..2.54 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=16784)
                    Index Cond: (id = statuses.account_id)
Planning time: 0.232 ms
Execution time: 6520.514 ms

After

Limit  (cost=0.70..78.49 rows=20 width=396) (actual time=0.048..0.410 rows=20 loops=1)
  ->  Nested Loop Left Join  (cost=0.70..327.40 rows=84 width=396) (actual time=0.048..0.407 rows=20 loops=1)
        Filter: (accounts.silenced_at IS NULL)
        Rows Removed by Filter: 1
        ->  Index Scan using index_statuses_local_20190824 on statuses  (cost=0.29..70.15 rows=101 width=396) (actual time=0.029..0.208 rows=21 loops=1)
              Filter: (account_id <> ALL ('{61919,125171,111310,77076,100948,103833,1633,1181,505,19662,7254,12537,12749,884,3033,645}'::bigint[]))
        ->  Index Scan using index_accounts_on_id on accounts  (cost=0.42..2.54 rows=1 width=16) (actual time=0.009..0.009 rows=1 loops=21)
              Index Cond: (id = statuses.account_id)
Planning time: 0.812 ms
Execution time: 0.443 ms

@Gargron Gargron added the performance Runtime performance label Aug 23, 2019
@Gargron
Copy link
Member Author

Gargron commented Aug 23, 2019

@abcang Does this look okay?

@Gargron Gargron merged commit aa6b5b4 into master Aug 24, 2019
@Gargron Gargron deleted the fix-slow-local-timeline branch August 24, 2019 02:12
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Runtime performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LTL is not displayed after applying #11623 in some instance
2 participants