3

I am looking to design a system that will have a primary database instance and replica copies. To keep INSERT performance good, the fewer indexes we have on the primary is desired versus adding more indexes on the read only copy.

Hoping to understand if it is possible to setup a binary replication strategy to create identical copies of primary in the read replicas -- BUT add indexes that are only on the replicas.

I am unable to find any guidance on this - hoping to get insights on how to proceed. Alternately is there other strategies - the desire here is to have a high performant primary for INSERT and UPDATES and offload all SELECTs to read only copies. Logic to DELETE would be best to read from a replica and execute actual delete on the primary (oh, the replication delay will not impact our delete if run this way).

TL;DR - can I create index only on a read REPLICA of a Postgres database.

dhul.takker
  • 161
  • 1
  • 5
  • 3
    No, not possible with streaming (=WAL shipping) replication. Your only option would be to use logical replication which is a bit more cumbersome to setup and maintain especially if you have many tables. –  Jul 12 '21 at 06:04
  • I am surprised that I was not getting good hits with this question - would have thought it would be a good design strategy! Thanks for the response - I will look into logical replication to see how to accomplish it. – dhul.takker Jul 12 '21 at 09:14
  • https://stackoverflow.com/questions/33621906/difference-between-stream-replication-and-logical-replication - this is a good discussion on various replication strategies. I speculate logical replication is looking better and better for what I need. – dhul.takker Jul 12 '21 at 09:31

0 Answers0