-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Jeff Amiel
Sent: Friday, December 02, 2011 3:20 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Oddball data distribution giving me planner headaches
explain analyze
select * from customer_rel where parent_customer in (select customer_id from customer where
customer_type='DISTRIBUTOR')
" Nested Loop (cost=25429.44..29626.39 rows=931 width=0) (actual time=216.325..1238.091 rows=1025401 loops=1)"
" -> HashAggregate (cost=25429.44..25430.80 rows=136 width=4) (actual time=216.304..216.339 rows=68 loops=1)"
" -> Seq Scan on customer (cost=0.00..25429.10 rows=136 width=4) (actual time=0.018..216.226 rows=68
loops=1)"
" Filter: (customer_type = 'DISTRIBUTOR'::bpchar)"
" -> Index Scan using rel_parent on customer_rel (cost=0.00..30.76 rows=7 width=4) (actual time=0.006..8.190
rows=15079loops=68)"
" Index Cond: (parent_customer = customer.customer_id)"
"Total runtime: 1514.810 ms"
------------------------------------------------------------
What kind of plan does the following give?
EXPLAIN ANALYZE
SELECT *
FROM customer_rel p
JOIN customer c ON (p.parent_customer = c.customer_id)
WHERE c.customer_type = 'DISTRIBUTOR'
;
David J.