Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D30E7B5DBE2 for ; Tue, 21 Jun 2011 00:25:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 90859-08 for ; Tue, 21 Jun 2011 03:25:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by mail.postgresql.org (Postfix) with ESMTP id 421F2B5DBCB for ; Tue, 21 Jun 2011 00:25:34 -0300 (ADT) Received: from [192.168.1.7] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LbxOG-1RI81g22uS-00jkwg; Tue, 21 Jun 2011 05:25:33 +0200 Message-ID: <4E000F2B.4000102@2ndQuadrant.com> Date: Mon, 20 Jun 2011 23:25:31 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110505 Icedove/3.0.11 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: Prepared statments: partial indexes are avoided! References: <4DC17AAB.1080206@hbs-research.com> <4DFF52BB.5060605@hbs-research.com> <4DFF5F5C.7040109@hbs-research.com> In-Reply-To: <4DFF5F5C.7040109@hbs-research.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:pWqDx26vucUJt5EU8xnieYgncGhZTEiwnU6bsX5VVU5 cVR8RXOmPYWQ9DB5LrSu4Gn7tvYnMfFnNiyH256U/AUQjzYfyJ FD96D+eIk0aPYhge3FpDrvZHc2Vp5zvLPRm8ilIw64+T9lJFbD dP6inr42AzErBhTtokBL0t+ujYSX2EGKc1Xu1Gl1+X5pcuLEyo ZE3ahTlvdfIzlgjr89oK6uoCOJcOvXMdqYPQI+qBsA= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201106/127 X-Sequence-Number: 37753 On 06/20/2011 10:55 AM, adrien ducos wrote: > I think this should at least be writen in this documentation: > http://www.postgresql.org/docs/9.0/static/indexes-partial.html > as a known limitation to avoid people spending hours of search for why > is the application becoming slow. It's documented in the "Notes" section of http://www.postgresql.org/docs/9.0/static/sql-prepare.html because it's not specific to partial indexes. Prepared statements are very risky when you run them against queries with a very skewed distribution, like your case where 99% of the values for a column are the same. They help to prevent SQL injection and can reduce parsing/planning overhead, but prepared statements can have terrible performance in some unfortunately common situations. Just recently I had one clients end up switching to another ORM specifically because they couldn't get the one they started with to stop using prepared statements, and those gave them terrible query plans. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books