Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2CF6D47707B for ; Fri, 4 Oct 2002 09:30:34 -0400 (EDT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 780B1476F53 for ; Fri, 4 Oct 2002 09:29:46 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 17xSWa-0004v6-0U; Fri, 04 Oct 2002 14:29:48 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 2EA8017191; Fri, 4 Oct 2002 14:29:54 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 953261718E; Fri, 4 Oct 2002 14:29:53 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Siva Kumar , pgsql-general@postgresql.org Subject: Re: Query optimization Date: Fri, 4 Oct 2002 14:29:51 +0100 User-Agent: KMail/1.4.3 References: <200210041347.55055.tech@leatherlink.net> <200210041114.17241.dev@archonet.com> <200210041756.35489.tech@leatherlink.net> In-Reply-To: <200210041756.35489.tech@leatherlink.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200210041429.51956.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/215 X-Sequence-Number: 31213 On Friday 04 Oct 2002 1:26 pm, Siva Kumar wrote: > Giving below the output of EXPLAIN ANALYSE. I could not make much sense o= ut > of it, please help! Scary aren't they ;-) The important thing is you've got plenty of "Index Scan"s rather than Seq= =20 Scans. The other point is the final time: > Total runtime: 5.45 msec Now, since that's not what you're getting, I'd think Neil (see other reply)= is=20 right and you need to look at issuing "SET geqo =3D off;" before the query. Postgresql has a genetic algorithm that kicks in on what it thinks is a ver= y=20 complex query, this can take a long time to analyse the options available b= ut=20 pays dividends on a big query. In your case you're only getting a few rows= =20 and so it takes longer to analyse than to get the results. The other thing that might work is rewriting the query with explicit JOINs = - I=20 think that should make it clear to Postgresql what order to do things in. - Richard Huxton