X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE6833A5B05 for ; Wed, 26 Jan 2005 08:50:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88613-01 for ; Wed, 26 Jan 2005 08:50:25 +0000 (GMT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 2C4B43A5B01 for ; Wed, 26 Jan 2005 08:50:26 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) id 1Ctisa-000Ako-F4; Wed, 26 Jan 2005 08:50:24 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id EB55E178E4; Wed, 26 Jan 2005 08:50:21 +0000 (GMT) Message-ID: <41F759CD.80709@archonet.com> Date: Wed, 26 Jan 2005 08:50:21 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joel Fradkin Cc: pgsql-sql@postgresql.org Subject: Re: Sorry I see my first question did not get posted (maybe References: <000e01c5035a$b989c140$797ba8c0@jfradkin> In-Reply-To: <000e01c5035a$b989c140$797ba8c0@jfradkin> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.073 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/248 X-Sequence-Number: 20036 Joel Fradkin wrote: > Basically the question was why would a view use an indexed search on one > result set but a seq search on a larger result set. Same view only > difference is how many rows are returned. The large result set was doing a > seq search and did not return after several minutes. The same sql ran in 135 > seconds on my MSSQL system. Accessing an index 1000 times then reading 1000 rows may be slower than just reading a whole table of 2000 rows. You can examine what PostgreSQL thinks the query will cost by running an explain: EXPLAIN ANALYSE SELECT ... This will display two sets of figures for each stage, the expected costs and the actual. Finally, make sure your configuration settings are reasonable. Read through the guide at: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php There's a -performance list that specialises in dealing with these issues. If you post there, mention you've tuned as per GeneralBits and provide an example of the query, view definition and the output from explain. -- Richard Huxton Archonet Ltd