• Production:

    before: timed out
    
    after:
    
                                                                                                QUERY PLAN
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     Aggregate  (cost=1747.32..1747.33 rows=1 width=8) (actual time=10456.703..10456.703 rows=1 loops=1)
       ->  Limit  (cost=1733.42..1747.31 rows=1 width=4) (actual time=10456.698..10456.698 rows=0 loops=1)
             ->  Nested Loop  (cost=1733.42..1747.31 rows=1 width=4) (actual time=10456.696..10456.696 rows=0 loops=1)
                   ->  HashAggregate  (cost=1732.86..1732.90 rows=4 width=4) (actual time=10456.695..10456.695 rows=0 loops=1)
                         Group Key: notes_1.id
                         ->  Append  (cost=0.56..1732.85 rows=4 width=4) (actual time=10456.690..10456.690 rows=0 loops=1)
                               ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_1  (cost=0.56..131.71 rows=1 width=4) (actual time=0.168..0.168 rows=0 loops=1)
                                     Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'Commit'::text))
                                     Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     Rows Removed by Filter: 28
                               ->  Nested Loop Semi Join  (cost=811.93..819.50 rows=1 width=4) (actual time=10440.126..10440.126 rows=0 loops=1)
                                     ->  Bitmap Heap Scan on notes notes_2  (cost=811.50..813.02 rows=1 width=8) (actual time=10440.121..10440.121 rows=0 loops=1)
                                           Recheck Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                           Rows Removed by Index Recheck: 4770
                                           Filter: ((project_id = 4088907) AND ((noteable_type)::text = 'Issue'::text))
                                           Rows Removed by Filter: 13068
                                           Heap Blocks: exact=6210
                                           ->  Bitmap Index Scan on index_notes_on_note_trigram  (cost=0.00..811.50 rows=1 width=0) (actual time=268.619..268.619 rows=17838 loops=1)
                                                 Index Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     ->  Index Scan using issues_pkey on issues  (cost=0.43..3.45 rows=1 width=4) (never executed)
                                           Index Cond: (id = notes_2.noteable_id)
                                           Filter: (project_id = 4088907)
                               ->  Nested Loop Semi Join  (cost=1.00..771.54 rows=1 width=4) (actual time=16.374..16.374 rows=0 loops=1)
                                     ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_3  (cost=0.56..765.07 rows=1 width=8) (actual time=16.370..16.370 rows=0 loops=1)
                                           Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'MergeRequest'::text))
                                           Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                           Rows Removed by Filter: 783
                                     ->  Index Scan using merge_requests_pkey on merge_requests  (cost=0.43..3.45 rows=1 width=4) (never executed)
                                           Index Cond: (id = notes_3.noteable_id)
                                           Filter: (target_project_id = 4088907)
                               ->  Nested Loop Semi Join  (cost=0.99..10.06 rows=1 width=4) (actual time=0.016..0.016 rows=0 loops=1)
                                     ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_4  (cost=0.56..3.59 rows=1 width=8) (actual time=0.013..0.013 rows=0 loops=1)
                                           Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'Snippet'::text))
                                           Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     ->  Index Scan using snippets_pkey on snippets  (cost=0.42..3.45 rows=1 width=4) (never executed)
                                           Index Cond: (id = notes_4.noteable_id)
                                           Filter: ((project_id = 4088907) AND ((type)::text = 'ProjectSnippet'::text))
                   ->  Index Scan using notes_pkey on notes  (cost=0.56..3.58 rows=1 width=4) (never executed)
                         Index Cond: (id = notes_1.id)
                         Filter: (NOT system)
     Planning time: 8.546 ms
     Execution time: 10456.958 ms
    (42 rows)

    Staging:

    before:
                                                                                           QUERY PLAN
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     Aggregate  (cost=1484.66..1484.67 rows=1 width=8) (actual time=22114.849..22114.849 rows=1 loops=1)
       ->  Nested Loop  (cost=1466.78..1484.66 rows=1 width=0) (actual time=22114.845..22114.845 rows=0 loops=1)
             ->  HashAggregate  (cost=1466.22..1466.26 rows=4 width=4) (actual time=22114.845..22114.845 rows=0 loops=1)
                   Group Key: notes_1.id
                   ->  Append  (cost=0.56..1466.21 rows=4 width=4) (actual time=22114.843..22114.843 rows=0 loops=1)
                         ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_1  (cost=0.56..188.12 rows=1 width=4) (actual time=2.196..2.196 rows=0 loops=1)
                               Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'Commit'::text))
                               Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                               Rows Removed by Filter: 1
                         ->  Nested Loop Semi Join  (cost=622.43..632.50 rows=1 width=4) (actual time=13760.041..13760.041 rows=0 loops=1)
                               ->  Bitmap Heap Scan on notes notes_2  (cost=622.00..624.02 rows=1 width=8) (actual time=13760.039..13760.039 rows=0 loops=1)
                                     Recheck Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     Rows Removed by Index Recheck: 4467
                                     Filter: ((project_id = 4088907) AND ((noteable_type)::text = 'Issue'::text))
                                     Rows Removed by Filter: 13002
                                     Heap Blocks: exact=5748
                                     ->  Bitmap Index Scan on index_notes_on_note_trigram  (cost=0.00..622.00 rows=1 width=0) (actual time=1951.078..1951.078 rows=17469 loops=1)
                                           Index Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                               ->  Index Scan using issues_pkey on issues  (cost=0.43..4.45 rows=1 width=4) (never executed)
                                     Index Cond: (id = notes_2.noteable_id)
                                     Filter: (project_id = 4088907)
                         ->  Nested Loop Semi Join  (cost=622.43..632.50 rows=1 width=4) (actual time=8351.672..8351.672 rows=0 loops=1)
                               ->  Bitmap Heap Scan on notes notes_3  (cost=622.00..624.02 rows=1 width=8) (actual time=8351.670..8351.670 rows=0 loops=1)
                                     Recheck Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     Rows Removed by Index Recheck: 4467
                                     Filter: ((project_id = 4088907) AND ((noteable_type)::text = 'MergeRequest'::text))
                                     Rows Removed by Filter: 13002
                                     Heap Blocks: exact=5748
                                     ->  Bitmap Index Scan on index_notes_on_note_trigram  (cost=0.00..622.00 rows=1 width=0) (actual time=124.230..124.230 rows=17469 loops=1)
                                           Index Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                               ->  Index Scan using merge_requests_pkey on merge_requests  (cost=0.43..4.45 rows=1 width=4) (never executed)
                                     Index Cond: (id = notes_3.noteable_id)
                                     Filter: (target_project_id = 4088907)
                         ->  Nested Loop Semi Join  (cost=0.98..13.06 rows=1 width=4) (actual time=0.932..0.932 rows=0 loops=1)
                               ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_4  (cost=0.56..4.59 rows=1 width=8) (actual time=0.931..0.931 rows=0 loops=1)
                                     Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'Snippet'::text))
                                     Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                               ->  Index Scan using snippets_pkey on snippets  (cost=0.42..4.45 rows=1 width=4) (never executed)
                                     Index Cond: (id = notes_4.noteable_id)
                                     Filter: ((project_id = 4088907) AND ((type)::text = 'ProjectSnippet'::text))
             ->  Index Scan using notes_pkey on notes  (cost=0.56..4.58 rows=1 width=4) (never executed)
                   Index Cond: (id = notes_1.id)
                   Filter: (NOT system)
     Planning time: 74.129 ms
     Execution time: 22116.007 ms
    (45 rows)
    
    after:
                                                                                              QUERY PLAN
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     Aggregate  (cost=1484.67..1484.68 rows=1 width=8) (actual time=16238.542..16238.542 rows=1 loops=1)
       ->  Limit  (cost=1466.78..1484.66 rows=1 width=4) (actual time=16238.538..16238.538 rows=0 loops=1)
             ->  Nested Loop  (cost=1466.78..1484.66 rows=1 width=4) (actual time=16238.537..16238.537 rows=0 loops=1)
                   ->  HashAggregate  (cost=1466.22..1466.26 rows=4 width=4) (actual time=16238.536..16238.536 rows=0 loops=1)
                         Group Key: notes_1.id
                         ->  Append  (cost=0.56..1466.21 rows=4 width=4) (actual time=16238.535..16238.535 rows=0 loops=1)
                               ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_1  (cost=0.56..188.12 rows=1 width=4) (actual time=0.031..0.031 rows=0 loops=1)
                                     Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'Commit'::text))
                                     Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     Rows Removed by Filter: 1
                               ->  Nested Loop Semi Join  (cost=622.43..632.50 rows=1 width=4) (actual time=8104.819..8104.819 rows=0 loops=1)
                                     ->  Bitmap Heap Scan on notes notes_2  (cost=622.00..624.02 rows=1 width=8) (actual time=8104.819..8104.819 rows=0 loops=1)
                                           Recheck Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                           Rows Removed by Index Recheck: 4467
                                           Filter: ((project_id = 4088907) AND ((noteable_type)::text = 'Issue'::text))
                                           Rows Removed by Filter: 13002
                                           Heap Blocks: exact=5748
                                           ->  Bitmap Index Scan on index_notes_on_note_trigram  (cost=0.00..622.00 rows=1 width=0) (actual time=109.873..109.873 rows=17469 loops=1)
                                                 Index Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     ->  Index Scan using issues_pkey on issues  (cost=0.43..4.45 rows=1 width=4) (never executed)
                                           Index Cond: (id = notes_2.noteable_id)
                                           Filter: (project_id = 4088907)
                               ->  Nested Loop Semi Join  (cost=622.43..632.50 rows=1 width=4) (actual time=8133.666..8133.666 rows=0 loops=1)
                                     ->  Bitmap Heap Scan on notes notes_3  (cost=622.00..624.02 rows=1 width=8) (actual time=8133.665..8133.665 rows=0 loops=1)
                                           Recheck Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                           Rows Removed by Index Recheck: 4467
                                           Filter: ((project_id = 4088907) AND ((noteable_type)::text = 'MergeRequest'::text))
                                           Rows Removed by Filter: 13002
                                           Heap Blocks: exact=5748
                                           ->  Bitmap Index Scan on index_notes_on_note_trigram  (cost=0.00..622.00 rows=1 width=0) (actual time=119.482..119.482 rows=17469 loops=1)
                                                 Index Cond: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     ->  Index Scan using merge_requests_pkey on merge_requests  (cost=0.43..4.45 rows=1 width=4) (never executed)
                                           Index Cond: (id = notes_3.noteable_id)
                                           Filter: (target_project_id = 4088907)
                               ->  Nested Loop Semi Join  (cost=0.98..13.06 rows=1 width=4) (actual time=0.017..0.017 rows=0 loops=1)
                                     ->  Index Scan using index_notes_on_project_id_and_noteable_type on notes notes_4  (cost=0.56..4.59 rows=1 width=8) (actual time=0.015..0.015 rows=0 loops=1)
                                           Index Cond: ((project_id = 4088907) AND ((noteable_type)::text = 'Snippet'::text))
                                           Filter: ((note ~~* '%Timed%'::text) AND (note ~~* '%out%'::text) AND (note ~~* '%waiting%'::text))
                                     ->  Index Scan using snippets_pkey on snippets  (cost=0.42..4.45 rows=1 width=4) (never executed)
                                           Index Cond: (id = notes_4.noteable_id)
                                           Filter: ((project_id = 4088907) AND ((type)::text = 'ProjectSnippet'::text))
                   ->  Index Scan using notes_pkey on notes  (cost=0.56..4.58 rows=1 width=4) (never executed)
                         Index Cond: (id = notes_1.id)
                         Filter: (NOT system)
     Planning time: 6.915 ms
     Execution time: 16238.717 ms
    (46 rows)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment