0

I successfully started logical replication on a testing environment. I generate insert on the master for some 60K records using procedure. While the insert process is running, i monitor the slave using "SELECT count(*)" query. But the records are not adding. If I run the query after the insert has finished on the primary, the SELECT count works fine, all records between slave and primary are equal.

Is this normal behaviour ? I am expecting the slave and primary to be exactly the same at almost instantly.

Thanks

2
  • 1
    You will only see the changes on the standby, when the transaction on the primary is committed.
    – user1822
    Aug 1, 2022 at 9:06
  • oh yes. make sense. It is waiting for commit. thanks
    – padjee
    Aug 3, 2022 at 5:31

1 Answer 1

0

It sounds like you expect to see the counts progressively change for one or a few records at a time. But as a_horse_with_no_name mentioned, if the 60k rows that are being inserted are all happening within the same transaction, then you won't see the changes until that transaction completes.

Even on the primary server, you wouldn't see the counts change individually, only the total count change at the end once the transaction is committed. This is the nature of transactions, one of their properties is Atomicity (of the ACID database principles), loosely meaning either all of the changes occur or none occur, there is no in-between.

1
  • yes. thank you. I was thinking it was auto-commit.
    – padjee
    Aug 3, 2022 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.