Expand description
Query-driven materialization of on-demand SQL views
Query-driven materialization of on-demand SQL views (DDL views with no update_group).
A query over query_range fills and refreshes the partitions covering that range, so nothing
is materialized for ranges nobody reads. The range is cut along the bucket ladder (see
partition_ladder), each bucket’s freshness is probed with the view’s own authored
count_src_query, and the stale ones are rewritten with its extract_query.
No partition is built from more source data than the view’s byte cap (max_jit_src_data),
except at the finest rung: a stale unit whose source bytes exceed the cap is rewritten as finer
ladder buckets, committed together with the retire of the unit’s rows, and promotion never
merges rows into a partition that would exceed the cap in bytes or in source bytes.
A bucket grows into a [Unit] that contains every partition row it intersects (an earlier
query at a coarser rung, a promotion, or rows left by the daemon before a view was converted),
so a write’s containment retire always replaces everything it overlaps and the verdict of a
unit never depends on another unit.
Structs§
- Unit
- A planned bucket, grown until it contains every partition row it intersects, and coalesced with the units it came to overlap.
Enums§
- Stale
Unit Plan - What to do with a unit judged stale.
- Unit
Verdict - Whether a unit’s rows already hold what its probe counted.
Functions§
- judge_
unit Coveredwhen the unit has rows, every row was written with the view’s current schema, and the rows’ summedsource_data_hashequals the count the probe returned. This is the maintenance daemon’s freshness rule (equality, summed), so a definition gets the same verdicts under either writer.- plan_
stale_ unit - A unit within the byte cap is written whole. Otherwise it is rebuilt as the leaves
plan_by_source_bytespicks, which replace the unit’s rows in one commit, however coarse those rows were. A unit that is itself one finest-rung bucket has nothing to split, so it is written whole whatever its size. - plan_
units - Grows each planned bucket until it contains every row that intersects it, then coalesces the
units that came to overlap.
plannedis ascending and non-overlapping. Rows are half-open against the unit (Aligned): SQL partitions touch at bucket edges, and a neighbor that merely touches is not absorbed. - promotion_
targets - Picks the units to promote: covered, closed, exactly one planned bucket at the query’s
rung(not grown).split_promotionthen decides what to merge within each, under the byte cap. Pure, likepromotion_candidates. - source_
bytes - Bytes of source data an extract over
rangereads: thefile_sizeof thesources’ partitions, each prorated by the share of its insert range that lies inrange. A zero-width partition counts whole when its insert time is in[begin, end). Prorating assumes data is spread evenly in insert time, which is good enough for a cap: extracts filter their sources by insert time. Partitions of other views, or of a source under another file schema, count for nothing. - split_
promotion - Picks what to merge within one covered, closed bucket: the whole of
rangewhenrowsmerge within the byte cap and a rebuild ofrangewould read at mostcapsource bytes. Otherwise, when the rows would merge but a cap is exceeded, each child bucket of the next finer rung gets the same treatment over the rows lying inside it. A child that a row straddles is skipped, since the row cannot be split. With fewer than two rows there is nothing to merge. - update_
on_ demand_ view - Brings an on-demand view up to date for
query_range: sizes buckets from the range, probes each one, rewrites the stale ones, then promotes closed history to the range’s rung.