Use of subquery causes seq scan???

From: "Chris Hoover" <revoohc(at)sermonaudio(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Use of subquery causes seq scan???
Date: 2004-04-20 14:20:05
Message-ID: 200404201020.05699.revoohc@sermonaudio.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I need some help. I have a query that refuses to use the provided index and
is always sequentially scanning causing me large performance headaches. Here
is the basic situation:

Table A:
inv_num int
type char
.
.
.
pkey (inv_num, type)
indx(inv_num)

Table B (has the same primary key)

Select *
from table a
where inv_num in (select inv_num from table b where ....)

Doing this causes sequential scans of both tables. If I do a set
enable_seqscan to false before the query, I get an index scan of table b but
still seq scan table a.

Is there anyway to force table a to use this index (or another) and not
sequentially scan the table?

I'm running 7.3.4 on RedHat EL 2.1.

Thanks,

Chris

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dirk Lutzebäck 2004-04-20 14:29:01 Re: Wierd context-switching issue on Xeon
Previous Message Matt Clark 2004-04-20 13:44:40 Re: Wierd context-switching issue on Xeon