Re: [SQL] SQL query _slow_ - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] SQL query _slow_
Date
Msg-id 8710.919698179@sss.pgh.pa.us
Whole thread Raw
List pgsql-sql
Bruce Momjian <maillist@candle.pha.pa.us> writes:
> Gregg Berkholtz <gregg@gbcomputers.com> writes:
>> Would indexes help at all? <-- If so, what should I index to get the best
>> speed?

> Not sure.  If EXPLAIN is slow showing results, it is just the optimizer.

Assuming Bruce has correctly diagnosed the problem (I think he has),
adding indexes would make things *worse* in 6.4.*, because it'd increase
the number of cases the optimizer has to consider.

Bruce fixed several bugs in the optimizer that were causing it to
consider far more combinations than it should in queries that join a
lot of tables.  So your query should work OK in 6.5, and at that point
you should try adding indexes to improve the speed of the actual query
(as opposed to the planning stage).

As a stopgap measure while you're using 6.4.*, try setting the GEQO
threshold to less than 7 tables.

            regards, tom lane

pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: HAVING confusion..
Next
From: "jose' soares"
Date:
Subject: Re: [SQL] SQL-Query 2 get primary key