Skip to content

Instantly share code, notes, and snippets.

@sorra
Created July 22, 2022 13:25
Show Gist options
  • Save sorra/5cfd6db2fcc2dcd95e0296294592225f to your computer and use it in GitHub Desktop.
Save sorra/5cfd6db2fcc2dcd95e0296294592225f to your computer and use it in GitHub Desktop.
QUERY PLAN
----------------------------------------
->  Sort  (cost=58696.04..58696.04 rows=1 width=553) (actual time=34338.192..34338.192 rows=0 loops=1)
        Sort Key: notifications.created_at DESC, notifications.id DESC
        Sort Method: quicksort  Memory: 25kB
    ->  Nested Loop  (cost=3800.49..58660.11 rows=1 width=20) (actual time=34338.162..34338.162 rows=0 loops=1)
        ->  Gather  (cost=3800.35..58659.94 rows=1 width=24) (actual time=34338.161..34339.487 rows=0 loops=1)
                Workers Planned: 2
                Workers Launched: 2
                ->  Nested Loop  (cost=2800.35..57659.84 rows=1 width=24) (actual time=34328.555..34328.555 rows=0 loops=3)
                    ->  Nested Loop  (cost=2799.78..57401.65 rows=31 width=20) (actual time=1684.157..34318.009 rows=1581 loops=3)
                            ->  Parallel Bitmap Heap Scan on shipments  (cost=2799.21..46196.17 rows=138 width=12) (actual time=1365.688..1385.022 rows=7047 loops=3)
                                Recheck Cond: (client_id = ANY (?::integer[]))
                                Filter: (status = ?)
                                Heap Blocks: exact=5882
                                ->  Bitmap Index Scan on index_shipments_on_client_id  (cost=0.00..2799.13 rows=22114 width=0) (actual time=1364.729..1364.729 rows=22367 loops=1)
                                        Index Cond: (client_id = ANY (?::integer[]))
                            ->  Index Scan using index_messages_on_messageable_type_and_messageable_id on messages  (cost=0.56..81.19 rows=1 width=12) (actual time=4.341..4.672 rows=0 loops=21142)
                                Index Cond: (((messageable_type)::text = 'Shipment'::text) AND (messageable_id = shipments.id))
                                Filter: (((assignee_id = ?) OR (assignee_id IS NULL)) AND (created_at >= ?::timestamp without time zone))
                                Rows Removed by Filter: 8
                    ->  Index Scan using index_notifications_on_user_id_and_object_id_and_created_at on notifications notifications_1  (cost=0.57..8.32 rows=1 width=12) (actual time=0.006..0.006 rows=0 loops=4743)
                            Index Cond: ((user_id = ?) AND (object_id = messages.id) AND (created_at >= ?::timestamp without time zone))
        ->  Index Scan using notification_types_pkey on notification_types  (cost=0.14..0.17 rows=1 width=4) (never executed)
                Index Cond: (id = notifications_1.notification_type_id)
                Filter: (((object_type)::text = 'message'::text) AND (domain = ?))
 Planning Time: 116.579 ms
 Execution Time: 34339.810 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment