dataegret / pgcompacttable

BSD 3-Clause "New" or "Revised" License
314 stars 48 forks source link

Question about --reindex-* parameters #45

Closed gglybin closed 2 years ago

gglybin commented 2 years ago

Hello,

Can you please clarify the following:

--reindex-replace
    Avoid using REINDEX INDEX CONCURRENTLY even when it is available. By
    default this native PostgreSQL feature is preferred.

--reindex-retry-count
    Attempts count to concurrently safe replace bloated index to new.
    Default 100

--reindex-retry-pause
    Pause between reindex attempts in seconds. Default is 1 second

--reindex-lock-timeout
    Statement timeout for reindex ALTER TABLE queries. Default is 1000
    (ms)

In my understanding if parameter --reindex-replace passed to your tool then only in this case there is a sense of defining the rest of --reindex-* options. Because in this case pgcompacttable will use not use native Postgres feature for index rebuild REINDEX INDEX CONCURRENTLY, but will perform steps like below: 1) Create new index concurrently; 2) Try to replace old index with new one (this is the place where --reindex-* can help to control this) 3) Drop old index.

If --reindex-replace is not passed to pgcompacttable then native Postgres feature for index rebuild REINDEX INDEX CONCURRENTLY will be used and setting additinal --reindex-* doesn't make any sense.

Am I right?

Thank you.

Melkij commented 2 years ago

Right, if you use postgresql 12 (or newer) and do not specify --reindex-replace - pgcompacttable will use native REINDEX INDEX CONCURRENTLY and other --reindex-* options makes no sence. But if you are using postgresql older than 12, --reindex-replace is implied.

I added --reindex-replace to force old logic just in case. Don't know why it might be preferable when native reindex concurrently is available.

gglybin commented 2 years ago

Thank you.