Abstract

A consistent query-result cache for PostgreSQL keeps the rows of every cached query in one shared cache table per origin relation, maintains those rows from the origin's logical replication stream, and, when a new query registers, checks whether an already-cached query's predicate region contains the new one so that population from the origin can be skipped. That check is all-or-nothing: a partly covered query re-fetches every row, including rows the cache already holds. This disclosure describes partial subsumption. The cache decomposes the new query's region into pieces, probes a constraint-containment index to find which pieces an exact, servable parent already holds, and splits the region into a covered part C and a residual R. It stamps the rows of C with the new query's generation, as full subsumption does, and populates only R from the origin with a synthesized query whose predicate is restricted to R, written as a set difference for IN-lists and as interval complements for ranges. The residual merges through the same snapshot watermark gate every population uses, so C and R both reflect the origin at the applied watermark when the query becomes servable. The split is taken only when C is a large share of the region; shapes whose residual cannot be expressed exactly populate in full.

Creative Commons License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.

Share

COinS