bug17213_explain.txt

text/plain

Filename: bug17213_explain.txt
Type: text/plain
Part: 0
Message: Re: BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize
                                                                                        QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Seq Scan on issues i1  (cost=0.00..123475.38 rows=1275 width=4) (actual time=0.815..0.945 rows=2 loops=1)
   Filter: (SubPlan 2)
   Rows Removed by Filter: 2
   SubPlan 2
     ->  Nested Loop  (cost=41.64..55.18 rows=2 width=0) (actual time=0.209..0.210 rows=1 loops=4)
           ->  Unique  (cost=41.48..41.49 rows=2 width=4) (actual time=0.180..0.180 rows=1 loops=4)
                 ->  Sort  (cost=41.48..41.49 rows=2 width=4) (actual time=0.175..0.175 rows=1 loops=4)
                       Sort Key: w3.issue_id
                       Sort Method: quicksort  Memory: 25kB
                       ->  Nested Loop  (cost=0.32..41.47 rows=2 width=4) (actual time=0.125..0.137 rows=1 loops=4)
                             ->  Nested Loop  (cost=0.17..41.05 rows=2 width=12) (actual time=0.110..0.121 rows=1 loops=4)
                                   ->  Seq Scan on watchers w3  (cost=0.00..1.03 rows=3 width=8) (actual time=0.012..0.013 rows=3 loops=4)
                                   ->  Memoize  (cost=0.17..17.13 rows=1 width=4) (actual time=0.034..0.034 rows=0 loops=12)
                                         Cache Key: w3.user_id
                                         Hits: 0  Misses: 12  Evictions: 11  Overflows: 0  Memory Usage: 1kB
                                         ->  Index Only Scan using users_pkey on users u1  (cost=0.15..17.12 rows=1 width=4) (actual time=0.029..0.029 rows=0 loops=12)
                                               Index Cond: (id = w3.user_id)
                                               Filter: (SubPlan 1)
                                               Rows Removed by Filter: 1
                                               Heap Fetches: 12
                                               SubPlan 1
                                                 ->  Nested Loop  (cost=0.15..10.28 rows=1 width=0) (actual time=0.013..0.013 rows=0 loops=12)
                                                       ->  Nested Loop  (cost=0.15..9.23 rows=1 width=0) (actual time=0.010..0.010 rows=0 loops=12)
                                                             ->  Seq Scan on watchers w1  (cost=0.00..1.04 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=12)
                                                                   Filter: ((user_id = u1.id) AND (i1.id = issue_id))
                                                                   Rows Removed by Filter: 2
                                                             ->  Index Only Scan using users_pkey on users u2  (cost=0.15..8.17 rows=1 width=4) (actual time=0.010..0.011 rows=1 loops=5)
                                                                   Index Cond: (id = u1.id)
                                                                   Heap Fetches: 5
                                                       ->  Seq Scan on watchers w2  (cost=0.00..1.04 rows=1 width=0) (actual time=0.003..0.003 rows=1 loops=5)
                                                             Filter: ((issue_id <> i1.id) AND (user_id = u1.id))
                                                             Rows Removed by Filter: 2
                             ->  Index Only Scan using users_pkey on users superfluous  (cost=0.15..0.21 rows=1 width=4) (actual time=0.010..0.010 rows=1 loops=4)
                                   Index Cond: (id = u1.id)
                                   Heap Fetches: 4
           ->  Index Only Scan using issues_pkey on issues i3  (cost=0.15..6.84 rows=1 width=4) (actual time=0.053..0.053 rows=1 loops=2)
                 Index Cond: (id = w3.issue_id)
                 Heap Fetches: 2
 Planning Time: 16.255 ms
 Execution Time: 1.642 ms
(40 rows)