Using index from sub-query - Mailing list pgsql-general

From pdaly
Subject Using index from sub-query
Date
Msg-id 39AA844A.B2C6F5DD@ix.netcom.com
Whole thread Raw
In response to Local Users "su'ing"  (andrew@ugh.net.au)
Responses Re: Using index from sub-query  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
As has been talked about recently, I have a int8 field, which when searched for
as 'value' will use the index, but as value, with the quotes will not.

I subquery to get a list of the values to look up:

SELECT [fields]
     FROM table1
     WHERE id in (
        select distinct id from namelookup where name = '$tname'
        )

When I do an explain on this, it is doing a table scan, and not using the index
table1.  It will only use the index when the value to be matched is in quotes.
How can I force it to use the index, or create a new index which would be used.

This causes a HUGE performance hit.  (30-45 seconds, as opposed to less than 1
second.)

Any help would be greatly appreciated!

-Pete


pgsql-general by date:

Previous
From: "jeff seaman"
Date:
Subject: RE: Postgresql on Solaris 8
Next
From: "Barnes, Sandy (Sandra)"
Date:
Subject: lo_creat() failing after 22 iterations