Re: Query planner issue - Mailing list pgsql-general

From Andrea Moretto
Subject Re: Query planner issue
Date
Msg-id 09B6D861-8394-4BE8-A75B-B90FB78FAA65@gmail.com
Whole thread Raw
In response to Re: Query planner issue  (Richard Huxton <dev@archonet.com>)
List 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.andrea@gmail.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.
-------------------------------------------------------


pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Stop trigger fireing for a specific user?
Next
From: Glyn Astill
Date:
Subject: Autovacuum, too often?