Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.2/8.9.1) with ESMTP id KAA51139 for ; Mon, 22 Feb 1999 10:43:39 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id KAA08712 for ; Mon, 22 Feb 1999 10:42:59 -0500 (EST) To: pgsql-sql@hub.org Subject: Re: [SQL] SQL query _slow_ In-reply-to: Your message of Sun, 21 Feb 1999 23:00:33 -0500 (EST) <199902220400.XAA82447@hub.org> Date: Mon, 22 Feb 1999 10:42:59 -0500 Message-ID: <8710.919698179@sss.pgh.pa.us> From: Tom Lane Bruce Momjian writes: > Gregg Berkholtz 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