Is it possible to create an index only on a replica, but not on the master?
sobes.tech AI
Answer from AI
In classical database replication architecture, indexes are created and maintained on the master, and then changes (including table and index structures) are replicated to the slaves. Creating an index only on the replica, but not on the master, is usually not possible because the replica is an exact copy of the master.
However, in some systems or when using logical replication, it is possible to manually create an index on the replica that does not exist on the master. This can be useful for optimizing queries that are executed only on the replica, for example, for analytics. But it is important to consider:
- Possible issues with consistency.
- The replica may cease to be an exact copy of the master.
- Some systems do not allow changing data structures on replicas.
Thus, technically it is possible, but it depends on the specific DBMS and the type of replication. In most cases, indexes are created on the master and automatically replicated.