Abstract
A query-result cache that stays consistent with a PostgreSQL origin database by consuming the origin's change stream admits a query on its first miss, copies the rows it needs from the origin, and thereafter applies each committed change to the copy in place or, when a change may grow the result, invalidates the cached query and copies the rows again on the next request. Under a write pattern that invalidates a query faster than clients request it, every population is wasted, and a few such queries can consume the cache's whole population capacity and a share of the origin's. This disclosure describes a demand-side control with three components sharing one bookkeeping structure. First, each cached query records consecutive wasted populations (populated, then invalidated having served fewer than a threshold of hits); after a streak of configured length the cache imposes an exponential, bounded cooldown during which the query is forwarded to the origin, and any hit-bearing population resets the streak. Second, at admission the cache compares a query's expected invalidation rate, from per-table change rates and per-shape history, with its request rate, and declines a query that cannot pay for registration and population. Third, a failsafe rejects queries whose source-row footprint dwarfs their result, such as unbounded scalar aggregates. A rejected or backed-off query is still answered, from the origin.
Creative Commons License

This work is licensed under a Creative Commons Attribution 4.0 License.
Recommended Citation
Nelson, James, "Churn-Aware Admission, Per-Query Repopulation Backoff and Failsafe Rejection of FootprintDominated Queries in a Consistent Query-Result Cache Maintained by Change Data Capture", Technical Disclosure Commons, ()
https://www.tdcommons.org/dpubs_series/13552