From: Richard Huxton <dev@archonet.com>
To: Josh Berkus <josh@agliodbs.com>
To: Greg Stark <gsstark@mit.edu>
Cc: Greg Stark <gsstark@mit.edu>
Cc: pgsql-performance@postgresql.org
Subject: Re: Planner matching constants across tables in a
Date: Wed, 5 Mar 2003 19:25:43 +0000
Message-ID: <200303051925.43178.dev@archonet.com> (raw)
In-Reply-To: <web-2881474@davinci.ethosmedia.com>
References: <web-2881474@davinci.ethosmedia.com>
On Wednesday 05 Mar 2003 7:00 pm, Josh Berkus wrote:
> Richard,
>
> > A domain defined as varchar() actually - which is why it's not using
> > an index,
> > but that's neither here nor there regarding the constant issue.
>
> You might improve your performance overall if you cast the constant to
> tel_num before doing the comparison in the query. Right now, the
> parser is casting the whole column to text instead, because it can't
> tell that the constant you supply is a valid tel_num.
That's what I thought, but...
rms=> EXPLAIN ANALYSE SELECT * FROM line WHERE telno='0912345 0004'::tel_num;
QUERY PLAN
----------------------------------------------------------------------------------------------
Seq Scan on line (cost=0.00..20.50 rows=1 width=28) (actual time=0.10..5.28
rows=1 loops=1)
Filter: ((telno)::text = ('0912345 0004'::character varying)::text)
Total runtime: 5.43 msec
rms=> EXPLAIN ANALYSE SELECT * FROM line WHERE telno='0912345 0004'::varchar;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
Index Scan using line_pkey on line (cost=0.00..5.78 rows=1 width=28) (actual
time=14.03..14.03 rows=1 loops=1)
Index Cond: ((telno)::character varying = '0912345 0004'::character
varying)
Total runtime: 14.28 msec
Ignoring the times (fake data on my test box) it seems like there's an issue
in comparing against DOMAIN defined types. Or maybe it's in the index
definition, although I don't know how to find out the type of an index.
--
Richard Huxton
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-performance@postgresql.org
Cc: dev@archonet.com, josh@agliodbs.com, gsstark@mit.edu
Subject: Re: Planner matching constants across tables in a
In-Reply-To: <200303051925.43178.dev@archonet.com>
References: <web-2881474@davinci.ethosmedia.com> <200303051925.43178.dev@archonet.com>
* 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