Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPFdO-0001i5-ET for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Jul 2016 20:59:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bPFdN-0006gk-Q4 for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Jul 2016 20:59:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bPFdN-0006gd-Bg for pgsql-bugs@postgresql.org; Mon, 18 Jul 2016 20:59:25 +0000 Received: from szalupa.batory.org.pl ([81.18.204.35]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bPFdK-00062P-Db for pgsql-bugs@postgresql.org; Mon, 18 Jul 2016 20:59:24 +0000 Received: from [192.168.0.14] (095160153253.dynamic-ww-10.vectranet.pl [95.160.153.253]) (authenticated bits=0) by szalupa.batory.org.pl (8.14.4/8.14.4) with ESMTP id u6IKxAMB013674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 18 Jul 2016 22:59:11 +0200 Subject: Re: Invalid indexes should not consume update overhead To: "Rader, David" , Peter Geoghegan References: <8b57a306-7951-8442-df16-8c581d61b4e6@ato.waw.pl> <578B6F00.3080104@ato.waw.pl> Cc: PostgreSQL Bugs , Greg Stark From: Tomasz Ostrowski Message-ID: <578D431D.1000601@ato.waw.pl> Date: Mon, 18 Jul 2016 22:59:09 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 81.18.204.35 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2016-07-17 23:06, Rader, David wrote: >> That seems pretty pointless. Why not actually drop the index, then? >> >> The only reason I can think of is that there is value in representing >> that indexes should continue to have optimizer statistics (that would >> happen for expression indexes in Postgres) without actually paying for >> the ongoing maintenance of the index during write statements. Even >> that seems like kind of a stretch, though. > > There's some DBA benefit in that the index disable also disables > constraints and foreign keys that depend on the index. instead of > having to drop and recreate dependent objects you can leave all the > definitions in place but disabled. So it makes laziness easier. > > Of course then you have to be sure that your data is right when you bulk > load since the engine is not enforcing it. To make it clear - I don't postulate disabling indexes used for data integrity - when the index can't be dropped, as for example some foreign key depends on it, or table primary key is based on it, then it should not be possible to turn it off. Also I don't postulate turning them back on without doing a full reindex - I just need to do this reindex for multiple indexes in parallel. What I'd like to have isn't really different than just dropping the indexes and recreating them back after bulk update. It's just that this operation is not very safe: - you have to save them somewhere else - using for example pg_dump, - pg_dump is often not available or is in wrong version, - when saving these indexes in some temporary directory you risk loosing them in case of a failure or crash, - provided that you're trying to code some application upgrade script, it's hard to tell what to do when previous execution crashed - when you save indexes again you risk overwriting your save with empty or incomplete data; when you don't, then you can't be sure if it was from some previous execution and there were some schema changes since. It's just it's now hard to prepare this for support team in sufficiently reliable way, so that they can do this bulk update on their own. And believe me - this trick works when you have a large table with large number (like tens) of indexes. Even more so if these indexes are of unicode text data. -- Regards, Tomasz "Tometzky" Ostrowski -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs