From: Andrew Biagioni <andrew.biagioni@e-greek.net>
To: pgsql-admin@postgresql.org
Subject: Matching indexes on int8 columns
Date: Fri, 24 Oct 2003 08:52:57 -0400
Message-ID: <OK85QLSNB0VRIDZFAUSNZWQO3UO21.3f9920a9@Laptop> (raw)
I'm running 7.3, and I recently found out something rather disconcerting: if I
have an index on an int8 column, and I run a query such as
SELECT * FROM [tablename] WHERE [colname] = 12345
the index is NOT used, and sequential scan of the 200K rows is done, taking ~
17500 msec.; if I change the query to be:
SELECT * FROM [tablename] WHERE [colname] = '12345'
or
SELECT * FROM [tablename] WHERE [colname] = 12345::int8
then the index is used and a btree index scan id performed taking ~24 msec.
I found this workaround in a 2001 thread, leading me to believe that it's
nothing new; however, there is nothing in the docs. that I could find
(including the Momjian book), that has any reference to this problem.
My conclusion is that index-to-WHERE matching relies on some strict kind of
type matching, without any attempt at type conversion between int4 and int8.
So finally, my question. Why is this behavior present? Is it actually a
feature that I don't know enough to appreciate?
Inquiring minds want to know...
Thanks,
Andrew Biagioni
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: andrew.biagioni@e-greek.net
Subject: Re: Matching indexes on int8 columns
In-Reply-To: <OK85QLSNB0VRIDZFAUSNZWQO3UO21.3f9920a9@Laptop>
References: <OK85QLSNB0VRIDZFAUSNZWQO3UO21.3f9920a9@Laptop>
* 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