public inbox for [email protected]help / color / mirror / Atom feed
Is a VACUUM or ANALYZE necessary after logical replication? 4+ messages / 4 participants [nested] [flat]
* Is a VACUUM or ANALYZE necessary after logical replication? @ 2024-06-15 22:55 Koen De Groote <[email protected]> 2024-06-15 23:13 ` Re: Is a VACUUM or ANALYZE necessary after logical replication? Adrian Klaver <[email protected]> 2024-06-16 07:09 ` Re: Is a VACUUM or ANALYZE necessary after logical replication? David G. Johnston <[email protected]> 0 siblings, 2 replies; 4+ messages in thread From: Koen De Groote @ 2024-06-15 22:55 UTC (permalink / raw) To: PostgreSQL General <[email protected]> I've gone over all of https://www.postgresql.org/docs/current/logical-replication.html and the only mentions of the word "index" I could find was in relation to replica identity and examples of table definitions showing primary key indexes. Nothing is said about indexes. Maybe for good reason, maybe they are fully functionality immediately after replication? So the main question: Once a table is fully replicated, do I need to vacuum(analyze) that table, or are the indexes on that table already functional? Regards, Koen De Groote ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is a VACUUM or ANALYZE necessary after logical replication? 2024-06-15 22:55 Is a VACUUM or ANALYZE necessary after logical replication? Koen De Groote <[email protected]> @ 2024-06-15 23:13 ` Adrian Klaver <[email protected]> 2024-06-16 06:54 ` Re: Is a VACUUM or ANALYZE necessary after logical replication? Achilleas Mantzios <[email protected]> 1 sibling, 1 reply; 4+ messages in thread From: Adrian Klaver @ 2024-06-15 23:13 UTC (permalink / raw) To: Koen De Groote <[email protected]>; PostgreSQL General <[email protected]> On 6/15/24 15:55, Koen De Groote wrote: > I've gone over all of > https://www.postgresql.org/docs/current/logical-replication.html > <https://www.postgresql.org/docs/current/logical-replication.html; and > the only mentions of the word "index" I could find was in relation to > replica identity and examples of table definitions showing primary key > indexes. > > Nothing is said about indexes. Maybe for good reason, maybe they are > fully functionality immediately after replication? > > So the main question: Once a table is fully replicated, do I need to > vacuum(analyze) that table, or are the indexes on that table already > functional? VACUUM/ANALYZE is not about making the index functional. The VACUUM marks the space dead tuples occupy in the table and associated indexes as available for recycling. The ANALYZE updates tables statistics to help the planner make decisions on what query plan to use. On a fresh table VACUUM will not be of much value, ANALYZE though will help by creating up to date table statistics. > > Regards, > Koen De Groote -- Adrian Klaver [email protected] ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is a VACUUM or ANALYZE necessary after logical replication? 2024-06-15 22:55 Is a VACUUM or ANALYZE necessary after logical replication? Koen De Groote <[email protected]> 2024-06-15 23:13 ` Re: Is a VACUUM or ANALYZE necessary after logical replication? Adrian Klaver <[email protected]> @ 2024-06-16 06:54 ` Achilleas Mantzios <[email protected]> 0 siblings, 0 replies; 4+ messages in thread From: Achilleas Mantzios @ 2024-06-16 06:54 UTC (permalink / raw) To: [email protected] Στις 16/6/24 02:13, ο/η Adrian Klaver έγραψε: > On 6/15/24 15:55, Koen De Groote wrote: >> I've gone over all of >> https://www.postgresql.org/docs/current/logical-replication.html >> <https://www.postgresql.org/docs/current/logical-replication.html; >> and the only mentions of the word "index" I could find was in >> relation to replica identity and examples of table definitions >> showing primary key indexes. >> >> Nothing is said about indexes. Maybe for good reason, maybe they are >> fully functionality immediately after replication? >> >> So the main question: Once a table is fully replicated, do I need to >> vacuum(analyze) that table, or are the indexes on that table already >> functional? > > VACUUM/ANALYZE is not about making the index functional. The VACUUM > marks the space dead tuples occupy in the table and associated indexes > as available for recycling. The ANALYZE updates tables statistics to > help the planner make decisions on what query plan to use. On a fresh > table VACUUM will not be of much value, ANALYZE though will help by > creating up to date table statistics. Hi Adrian, however in case the replication is problematic due to e.g. : - wrong encoding to the new system, e.g. from SQL_ASCII to UTF-8 - ALWAYS triggers written without full schema qualification or other problems throwing ERRORs, etc - server restarts during the sync phase - etc those will produce rollbacks, hence bloating right from the start. In those cases either VACUUM FULL will be needed, or even better correct the errors in their source and repeat the whole process. Normally the new DB (subscriber) should be a little smaller than the original (publisher). As you said, in any case, ANALYZE will be always needed afterwards, as well as taking care of sequences. IMHO the sequence part would be nice to be handled in a more elegant manner, e.g. by an option in pg_dump to dump only sequences, for "nearly zero" downtime upgrades, this step should happen rapidly at the switchover. > >> >> Regards, >> Koen De Groote > -- Achilleas Mantzios IT DEV - HEAD IT DEPT Dynacom Tankers Mgmt (as agents only) ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is a VACUUM or ANALYZE necessary after logical replication? 2024-06-15 22:55 Is a VACUUM or ANALYZE necessary after logical replication? Koen De Groote <[email protected]> @ 2024-06-16 07:09 ` David G. Johnston <[email protected]> 1 sibling, 0 replies; 4+ messages in thread From: David G. Johnston @ 2024-06-16 07:09 UTC (permalink / raw) To: Koen De Groote <[email protected]>; +Cc: PostgreSQL General <[email protected]> On Saturday, June 15, 2024, Koen De Groote <[email protected]> wrote: > I've gone over all of https://www.postgresql.org/docs/current/logical- > replication.html and the only mentions of the word "index" I could find > was in relation to replica identity and examples of table definitions > showing primary key indexes. > > Nothing is said about indexes. Maybe for good reason, maybe they are fully > functionality immediately after replication? > > So the main question: Once a table is fully replicated, do I need to > vacuum(analyze) that table, or are the indexes on that table already > functional? > The whole point of “logical” replication is that the inserts/updates/deletes are reapplied on the secondary against the table and the whatever triggers, indexes, or whatnot exist on that table in the secondary behave just as if you connected to the server directly and issued the corresponding SQL against it. As far as the replication system is concerned none of those things on the primary matter nor does it have to care about them on the secondary. David J. ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-06-16 07:09 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-06-15 22:55 Is a VACUUM or ANALYZE necessary after logical replication? Koen De Groote <[email protected]> 2024-06-15 23:13 ` Adrian Klaver <[email protected]> 2024-06-16 06:54 ` Achilleas Mantzios <[email protected]> 2024-06-16 07:09 ` David G. Johnston <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox