Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erNsK-0005cL-Nk for pgsql-performance@arkaria.postgresql.org; Thu, 01 Mar 2018 13:03:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erNsJ-0003zT-I9 for pgsql-performance@arkaria.postgresql.org; Thu, 01 Mar 2018 13:03:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erNsJ-0003zK-78 for pgsql-performance@lists.postgresql.org; Thu, 01 Mar 2018 13:03:55 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1erNsE-0008IP-O2 for pgsql-performance@lists.postgresql.org; Thu, 01 Mar 2018 13:03:53 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id B2AE842F23; Thu, 1 Mar 2018 14:03:46 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id AW_kbTlcip9a; Thu, 1 Mar 2018 14:03:30 +0100 (CET) Message-ID: <1519909408.6586.5.camel@cybertec.at> Subject: Re: Performance degrade in Planning Time to find appropriate Partial Index From: Laurenz Albe To: Meenatchi Sandanam , pgsql-performance@lists.postgresql.org Date: Thu, 01 Mar 2018 14:03:28 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Meenatchi Sandanam wrote: > I have created a table with 301 columns(ID, 150 BIGINT, 150 TEXT). The table contains > multiple form data differentiated by ID range. Hence a column contains more than one form data. > To achieve Unique Constraint and Indexing per form, I chose PostgreSQL Partial Indexes > which suits my requirement. I have created Partial Indexes with ID Range as criteria and > it provides Uniqueness and Indexing per form basis as expected. But DML operations on a > particular form scans all the Indexes created for the entire table instead of scanning > the Indexes created for that particular form ID Range. This degrades Planner Performance > and Query Time more than 10 times as below, > > Query Result for the table with 3000 Partial Indexes(15 Indexes per form) : It is crazy to create 3000 partial indexes on one table. No wonder planning and DML statements take very long, they have to consider all the indexes. > explain analyse select id from form_data_copy where id between 3001 and 4000 and bigint50=789; Use a single index on (bigint50, id) for best performance. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com