pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Russell Smith <mr-russ@pws.com.au>
Cc: Tom Pfeifer <tpfeifer@tela.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index use and slow queries
Date: Sun, 13 Mar 2005 01:26:12 -0500
Message-ID: <14749.1110695172@sss.pgh.pa.us> (raw)
In-Reply-To: <200503131707.46690.mr-russ@pws.com.au>
References: <20050313051830.M98712@tela.com>
	<200503131707.46690.mr-russ@pws.com.au>

Russell Smith <mr-russ@pws.com.au> writes:
> On Sun, 13 Mar 2005 04:40 pm, Tom Pfeifer wrote:
>> I get really slow repoonse times when using the following select statement (About 20 seconds). 
>> maach=# explain select * from tst where tst_id = 639246; 

> Before 8.0, bigint would not use an index unless you cast it, or quote it.

> explain select * from tst where tst_id = 639246::int8; 
> explain select * from tst where tst_id = '639246'; 

... or you compare to a value large enough to be int8 naturally, eg

> explain select * from tst where tst_id = 123456639246;

The issue here is that (a) 639246 is naturally typed as int4, and
(b) before 8.0 we couldn't use cross-type comparisons such as int8 = int4
with an index.

You can find a whole lot of angst about this issue and related ones
if you care to review the last six or eight years of the pgsql-hackers
archives.  It was only recently that we found a way to support
cross-type index operations without breaking the fundamental
type-extensibility features of Postgres.  (In hindsight, we spent way
too much time fixated on the notion that we needed to find a way to
implicitly convert the non-indexed value to match the indexed column's
type, rather than biting the bullet and supporting cross-type operations
directly with indexes.  Oh well, hindsight is always 20/20.)

			regards, tom lane



view thread (3+ messages)

Message-ID: <14749.1110695172@sss.pgh.pa.us>
Permalink:  ../14749.1110695172@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14749.1110695172@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mr-russ@pws.com.au, tpfeifer@tela.com
  Subject: Re: Index use and slow queries
  In-Reply-To: <14749.1110695172@sss.pgh.pa.us>

* 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