Global Tables vs Duplicate Indexes

With CockroachDB version 21.1, a new concept of “global tables” was introduced. This functionality is a good fit for situations where read latency on a table needs to be very low and write latency can be much higher than normal [read: it needs to be fast when doing lookups, but we can tolerate lengthy writes]. It is also a fit for when reads must be up to date for business reasons or because the table is referenced by foreign keys or where latency-critical reads cannot be tied to specific regions. So using the global tables functionality is ideal for any kind of reference table, where we want to get the data out very quickly, but we can handle long inserts and updates.

With global tables, the lengthy writes go about doing all the pre-work to prevent any contention and serializable errors that we would traditionally see. When we read from the table, all the work has previously been done to avoid any contention and we can access the closest replica and read from it, effectively as if we were doing a follower read but in real time.