Re: Query planner issue

From: Andrea Moretto <moretto(dot)andrea(at)gmail(dot)com>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Query planner issue
Date: 2008-09-19 10:48:49
Message-ID: 09B6D861-8394-4BE8-A75B-B90FB78FAA65@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear Richard,

you are right. So Postgres takes a lot of time to get out an
impossible result!
The query I wrote is just a test, the concatenation is only a dummy.

On 19/set/08, at 12:33, Richard Huxton wrote:

> Andrea Moretto wrote:
>> I've got a table called DETAILS, the primary key is : DE_ID char(12),
>> there is another field CO_ID char (12).
>
>> If I run "explain analyze select * from details where co_id ||
>> co_id =
>> '0100760153722324445';" it runs a sequential scan not using the index
>> (which takes about 1000000 times than using the index):
>
> That query can never return any rows. You're appending co_id to itself
> then testing against a non-repeating string. Furthermore it's 19 chars
> long rather than 24. Is this really what you're trying to do?
>
> Read up on "indexes on expressions" in chapter 11 of the manuals, for
> indexing this sort of thing. I don't think it will help you here
> though.
>
> --
> Richard Huxton
> Archonet Ltd

Andrea Moretto
moretto(dot)andrea(at)gmail(dot)com
-------------------------------------------------------
CONFIDENTIALITY NOTICE
This message and its attachments are addressed solely to the persons
above and may contain confidential information. If you have received
the message in error, be informed that any use of the content hereof
is prohibited. Please return it immediately to the sender and delete
the message.
-------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Glyn Astill 2008-09-19 10:52:35 Autovacuum, too often?
Previous Message Richard Huxton 2008-09-19 10:35:16 Re: Stop trigger fireing for a specific user?