pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15987: Improve REINDEX of all indexes of a table at once
5+ messages / 5 participants
[nested] [flat]

* BUG #15987: Improve REINDEX of all indexes of a table at once
@ 2019-08-31 17:15  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 5+ messages in thread

From: PG Bug reporting form @ 2019-08-31 17:15 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: hellojo180@yahoo.es

The following bug has been logged on the website:

Bug reference:      15987
Logged by:          Jo Tzschenscher
Email address:      hellojo180@yahoo.es
PostgreSQL version: 10.10
Operating system:   RHEL
Description:        

Hello, 

PLEASE ROUTE THIS PROPOSAL TO A  DEVELOPMENT TEAM, IT PROPOSES AN IMPROVED
FEATURE.

I am just spending lots of time to rebuild the indexes of our DB one by one,
although all indexes of the same table need a refresh at once, Therefore you
need to open a cursor which contains the DB-columns which occur in at least
one of the indexes. If the same columns occur in more than 1 index you need
to read them only once. Then you run 1 and only 1 full table scan (FTS), and
with the data of the cursor you add an entry into each of the indexes to
rebuild. With just 1 FTS you could create all the indexes at once, and
speeding up a full reindex task to use little more than the time the FTS
takes.

Thank you for listening. 

Have a nice day. Cheerio. 

Jo



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15987: Improve REINDEX of all indexes of a table at once
@ 2019-09-01 04:35  Michael Paquier <michael@paquier.xyz>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2019-09-01 04:35 UTC (permalink / raw)
  To: hellojo180@yahoo.es; pgsql-bugs@lists.postgresql.org

On Sat, Aug 31, 2019 at 05:15:10PM +0000, PG Bug reporting form wrote:
> I am just spending lots of time to rebuild the indexes of our DB one by one,
> although all indexes of the same table need a refresh at once, Therefore you
> need to open a cursor which contains the DB-columns which occur in at least
> one of the indexes. If the same columns occur in more than 1 index you need
> to read them only once. Then you run 1 and only 1 full table scan (FTS), and
> with the data of the cursor you add an entry into each of the indexes to
> rebuild. With just 1 FTS you could create all the indexes at once, and
> speeding up a full reindex task to use little more than the time the FTS
> takes.

I don't quite understand your request.  You have REINDEX TABLE which
is able to reindex all the indexes of a table one by one, REINDEX
SCHEMA which works on all the tables of the defined schema, and
REINDEX DATABASE which works on all the indexes within a database
which processes in a serializable fashion all its tables.

If you have indexes are defined multiple times for the same columns
and you'd like to just process these, you may not need those multiple
definitions.  Please note that if you have multiple indexes on the
same table which partially map to the same columns, you still need to
process them one-by-one.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15987: Improve REINDEX of all indexes of a table at once
@ 2019-09-01 09:45  Fabien COELHO <coelho@cri.ensmp.fr>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 2 replies; 5+ messages in thread

From: Fabien COELHO @ 2019-09-01 09:45 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: hellojo180@yahoo.es, PostgreSQL Bugs <pgsql-bugs@lists.postgresql.org>



>> one of the indexes. If the same columns occur in more than 1 index you need
>> to read them only once. Then you run 1 and only 1 full table scan (FTS), and
>> with the data of the cursor you add an entry into each of the indexes to
>> rebuild. With just 1 FTS you could create all the indexes at once, and
>> speeding up a full reindex task to use little more than the time the FTS
>> takes.
>
> I don't quite understand your request.  You have REINDEX TABLE which
> is able to reindex all the indexes of a table one by one, […]

I understood the request as the scan should be factored out, so that 
reindexing a table with multiple indexes would cost only one seq scan.

-- 
Fabien.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15987: Improve REINDEX of all indexes of a table at once
@ 2019-09-01 11:18  Jo Tzschenscher <hellojo180@yahoo.es>
  parent: Fabien COELHO <coelho@cri.ensmp.fr>
  1 sibling, 0 replies; 5+ messages in thread

From: Jo Tzschenscher @ 2019-09-01 11:18 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: PostgreSQL Bugs <pgsql-bugs@lists.postgresql.org>

Totally correct, Fabien!


    En domingo, 1 de septiembre de 2019 11:45:57 CEST, Fabien COELHO <coelho@cri.ensmp.fr> escribió:  
 
 

>> one of the indexes. If the same columns occur in more than 1 index you need
>> to read them only once. Then you run 1 and only 1 full table scan (FTS), and
>> with the data of the cursor you add an entry into each of the indexes to
>> rebuild. With just 1 FTS you could create all the indexes at once, and
>> speeding up a full reindex task to use little more than the time the FTS
>> takes.
>
> I don't quite understand your request.  You have REINDEX TABLE which
> is able to reindex all the indexes of a table one by one, […]

I understood the request as the scan should be factored out, so that 
reindexing a table with multiple indexes would cost only one seq scan.

-- 
Fabien.  

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15987: Improve REINDEX of all indexes of a table at once
@ 2019-09-01 15:36  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Fabien COELHO <coelho@cri.ensmp.fr>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2019-09-01 15:36 UTC (permalink / raw)
  To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Michael Paquier <michael@paquier.xyz>; hellojo180@yahoo.es, PostgreSQL Bugs <pgsql-bugs@lists.postgresql.org>

Fabien COELHO <coelho@cri.ensmp.fr> writes:
>> I don't quite understand your request.  You have REINDEX TABLE which
>> is able to reindex all the indexes of a table one by one, […]

> I understood the request as the scan should be factored out, so that 
> reindexing a table with multiple indexes would cost only one seq scan.

I'm not totally convinced that that would be an improvement.
For starters, one would presumably have to divide up maintenance_work_mem
per index, which would be a substantial penalty for some index types.
Also, you'd be creating more randomized I/O on the index-writing side
of the equation (for those index types that write the index during the
scan).

It might net out as a win anyway depending on context, but I don't
think it's as clear-cut as the OP seems to think.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2019-09-01 15:36 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-31 17:15 BUG #15987: Improve REINDEX of all indexes of a table at once PG Bug reporting form <noreply@postgresql.org>
2019-09-01 04:35 ` Michael Paquier <michael@paquier.xyz>
2019-09-01 09:45   ` Fabien COELHO <coelho@cri.ensmp.fr>
2019-09-01 11:18     ` Jo Tzschenscher <hellojo180@yahoo.es>
2019-09-01 15:36     ` Tom Lane <tgl@sss.pgh.pa.us>

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