Re: Query planner issue - Mailing list pgsql-general

From Richard Huxton
Subject Re: Query planner issue
Date
Msg-id 48D38005.3010204@archonet.com
Whole thread Raw
In response to Query planner issue  (Andrea Moretto <moretto.andrea@gmail.com>)
Responses Re: Query planner issue
List pgsql-general
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

pgsql-general by date:

Previous
From: Andrea Moretto
Date:
Subject: Query planner issue
Next
From: Richard Huxton
Date:
Subject: Re: Stop trigger fireing for a specific user?