Why this Query Plan is different - Mailing list pgsql-admin

From Thilina Gunasekara
Subject Why this Query Plan is different
Date
Msg-id 20050324040117.87BC753582@svr1.postgresql.org
Whole thread Raw
Responses Re: Why this Query Plan is different
List 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


pgsql-admin by date:

Previous
From: "dedy"
Date:
Subject: How to move the ...
Next
From: Bruce Momjian
Date:
Subject: Re: 7.4.5 file write issue