| From: | "Thilina Gunasekara" <tgunasekara(at)openworld(dot)org> |
|---|---|
| To: | "PGSQL Admin" <pgsql-admin(at)postgresql(dot)org> |
| Subject: | Why this Query Plan is different |
| Date: | 2005-03-24 04:00:48 |
| Message-ID: | 20050324040117.87BC753582@svr1.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
Dear All,
I have two PostgreSQL Database Servers running on Gentoo which versions are
PostgreSQL 7.4.5 (Box A) and PostgreSQL 7.3.9 (Box B)
Due to a recent query posted by a developer I was interested to know which
factors are affecting these two servers to behave in a different manner to
the same query. Please shed light on this.
Box A (PostgreSQL 7.4.5) -
EXPLAIN SELECT count(airport_code) FROM properties WHERE
airport_code::character varying IN (SELECT airport_code::character varying
FROM airport_codes);
QUERY PLAN
----------------------------------------------------------------------------
Aggregate (cost=3605245.81..3605245.81 rows=1 width=4)
-> Seq Scan on properties (cost=0.00..3605195.64 rows=20068 width=4)
Filter: (subplan)
SubPlan
-> Seq Scan on airport_codes (cost=0.00..179.54 rows=7654
width=7)
Box B (PostgreSQL 7.3.9) - This take much to process
production=# EXPLAIN SELECT count(airport_code) FROM properties WHERE
airport_code::character varying IN (SELECT airport_code::character varying
FROM airport_codes);
QUERY PLAN
----------------------------------------------------------------------------
Aggregate (cost=9421.05..9421.05 rows=1 width=13)
-> Hash IN Join (cost=228.67..9320.65 rows=40158 width=13)
Hash Cond: ((("outer".airport_code)::character varying)::text =
(("inner".airport_code)::character varying)::text)
-> Seq Scan on properties (cost=0.00..2137.58 rows=40158
width=13)
-> Hash (cost=179.54..179.54 rows=7654 width=7)
-> Seq Scan on airport_codes (cost=0.00..179.54 rows=7654
width=7)
Thilina Gunasekara
Database Administrator
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2005-03-24 05:19:18 | Re: 7.4.5 file write issue |
| Previous Message | dedy | 2005-03-24 03:12:30 | How to move the ... |