Re: How can I speed up this search?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I speed up this search?
Date: 2002-05-08 04:33:55
Message-ID: 29083.1020832435@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
> I am searching on a FULL JOIN of two tables (using 7.2.1). VACUUM
> ANALYZE has been done.

> If I search on either of them separately, the search uses the
> appropriate index, but when they are joined, the second table uses a
> sequential scan and takes far longer than (I think) it ought. Can I
> reshape the query or add additional indexes to improve the planner's
> guess?

I am guessing that the problem has something to do with the fact that
the indexed columns are integer in one table and smallint in the other.
Yet in my tests both 7.2 and current sources can figure out how to do an
indexed mergejoin between integer and smallint columns. Strange that
it's not doing that for you.

Can you try (a) remaking the tables with identical column types;
(b) removing the product_currency_index index to see if the planner
will use the other index when it has no choice?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-05-08 05:26:10 Re: Logging function calls to figure out lo_close log entries?
Previous Message Ron Snyder 2002-05-08 02:08:21 Logging function calls to figure out lo_close log entries?