optimizer not optimizing

From: Albert Vernon Smith <contact1(at)absentia(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: optimizer not optimizing
Date: 2005-06-30 19:43:47
Message-ID: 9DCCFBD9-472E-48F6-BA9F-D601F31DB28D@absentia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am in process of migrating from Pg 7.4.5 to 8.0.3. I have the same
data loaded in to the two. However, when I do a query on my 8.0.3
installation, I am not getting a very well optimized query. (All the
memory settings are equivalent.)

On 8.0.3, I get the following query plan:

dbsnp_b125=# explain select * from b125_snpcontigloc_34_3 h join
b125_contiginfo_34_3 c on c.ctg_id=h.ctg_id and c.contig_label=
'reference' join b125_snpmapinfo_34_3 m on m.snp_id=h.snp_id and
m.assembly = 'reference' limit 50;
QUERY
PLAN
------------------------------------------------------------------------
---------------------------------------------------------------
Limit (cost=13.17..23330.15 rows=50 width=1324)
-> Nested Loop (cost=13.17..63181113458.28 rows=135483020
width=1324)
Join Filter: ("outer".snp_id = "inner".snp_id)
-> Index Scan using i_assembly_snpmapinfo_34 on
b125_snpmapinfo_34_3 m (cost=0.00..391516.14 rows=113292 width=204)
Index Cond: ((assembly)::text = 'reference'::text)
-> Hash Join (cost=13.17..554703.83 rows=239175 width=1120)
Hash Cond: ("outer".ctg_id = "inner".ctg_id)
-> Seq Scan on b125_snpcontigloc_34_3 h
(cost=0.00..472573.94 rows=15944994 width=676)
-> Hash (cost=13.16..13.16 rows=3 width=444)
-> Index Scan using
i_contiginfo_contig_label_125 on b125_contiginfo_34_3 c
(cost=0.00..13.16 rows=3 width=444)
Index Cond: ((contig_label)::text =
'reference'::text)
(11 rows)

While on 7.4.3, I get:

dbsnp_b125=# explain select * from b125_snpcontigloc_34_3 h join
b125_contiginfo_34_3 c on c.ctg_id=h.ctg_id and c.contig_label=
'reference' join b125_snpmapinfo_34_3 m on m.snp_id=h.snp_id and
m.assembly = 'reference' limit 50;
QUERY PLAN
------------------------------------------------------------------------
-------------------------------------------------------
Limit (cost=0.00..318.79 rows=50 width=441)
-> Nested Loop (cost=0.00..1019222.39 rows=159859 width=441)
-> Nested Loop (cost=0.00..313911.04 rows=175220 width=359)
-> Index Scan using i_b125_34_contig_label on
b125_contiginfo_34_3 c (cost=0.00..6.75 rows=3 width=252)
Index Cond: ((contig_label)::text =
'reference'::text)
-> Index Scan using i_b125h_34_ctg_id on
b125_snpcontigloc_34_3 h (cost=0.00..103904.68 rows=58407 width=107)
Index Cond: ("outer".ctg_id = h.ctg_id)
-> Index Scan using i_b125_map_34_snp_id on
b125_snpmapinfo_34_3 m (cost=0.00..4.01 rows=1 width=82)
Index Cond: (m.snp_id = "outer".snp_id)
Filter: ((assembly)::text = 'reference'::text)
(10 rows)

What could be the reason for this behavior???

(I posted something similar a little while back, but I've still not
solved this issue.)

Thanks,
-albert

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2005-06-30 20:15:04 Re: Error while installing Slony 1.1.0 for PostGreSql version 7.3.4
Previous Message Tony Caduto 2005-06-30 19:27:03 Re: COnsidering a move away from Postgres