From: Thilina Gunasekara <tgunasekara@openworld.org>
To: PGSQL Admin <pgsql-admin@postgresql.org>
Subject: Why this Query Plan is different
Date: Thu, 24 Mar 2005 10:00:48 +0600
Message-ID: <20050324040117.87BC753582@svr1.postgresql.org> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgunasekara@openworld.org
Subject: Re: Why this Query Plan is different
In-Reply-To: <20050324040117.87BC753582@svr1.postgresql.org>
References: <20050324040117.87BC753582@svr1.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox