pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Ostrowski <tometzky+pg@ato.waw.pl>
To: Rader, David <davidr@openscg.com>
To: Peter Geoghegan <pg@heroku.com>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Cc: Greg Stark <stark@mit.edu>
Subject: Re: Invalid indexes should not consume update overhead
Date: Mon, 18 Jul 2016 22:59:09 +0200
Message-ID: <578D431D.1000601@ato.waw.pl> (raw)
In-Reply-To: <CAABt7R6BnEnmnuehXtXtzKi0Up3NxwvAqX0ugjCaLm52VyhH9g@mail.gmail.com>
References: <8b57a306-7951-8442-df16-8c581d61b4e6@ato.waw.pl>
	<CAM-w4HN00MFSMwi+CF-Z9TFG4Xj8gq35zvN0yD=XT-X9y0z0Wg@mail.gmail.com>
	<578B6F00.3080104@ato.waw.pl>
	<CAM3SWZTXBg3AC75kgs9XYvY99ru1QkDJZoS_wyi8XrQFV90U9A@mail.gmail.com>
	<CAABt7R7WcB1wHhe_RgFLjBNFkWREumMyBTQUaLFo_5_LQ3ft_g@mail.gmail.com>
	<CAM3SWZRKUqdPeh5aGGg6BydBWxFL+fySmx5xdoWzCUBCCD5W2Q@mail.gmail.com>
	<CAABt7R6BnEnmnuehXtXtzKi0Up3NxwvAqX0ugjCaLm52VyhH9g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (14+ messages)

Message-ID: <578D431D.1000601@ato.waw.pl>
Permalink:  ../578D431D.1000601@ato.waw.pl/
Also on:    postgresql.org/message-id/578D431D.1000601@ato.waw.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tometzky+pg@ato.waw.pl, davidr@openscg.com, pg@heroku.com, stark@mit.edu
  Subject: Re: Invalid indexes should not consume update overhead
  In-Reply-To: <578D431D.1000601@ato.waw.pl>
  References: <8b57a306-7951-8442-df16-8c581d61b4e6@ato.waw.pl> <CAM-w4HN00MFSMwi+CF-Z9TFG4Xj8gq35zvN0yD=XT-X9y0z0Wg@mail.gmail.com> <578B6F00.3080104@ato.waw.pl> <CAM3SWZTXBg3AC75kgs9XYvY99ru1QkDJZoS_wyi8XrQFV90U9A@mail.gmail.com> <CAABt7R7WcB1wHhe_RgFLjBNFkWREumMyBTQUaLFo_5_LQ3ft_g@mail.gmail.com> <CAM3SWZRKUqdPeh5aGGg6BydBWxFL+fySmx5xdoWzCUBCCD5W2Q@mail.gmail.com> <CAABt7R6BnEnmnuehXtXtzKi0Up3NxwvAqX0ugjCaLm52VyhH9g@mail.gmail.com> <578D431D.1000601@ato.waw.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox