Class E204_TreePrefilter

Assembly: redb.Examples.dll

Tree counterpart of E202: dumps the SQL a tree query generates with and without the PVT
prefilter, and checks that the row count is unchanged. See docs/PVT_PREFILTER_PLAN.md.
dotnet run --project redb.Examples -- E204 (off)
REDB_PVT_PREFILTER=1 dotnet run --project redb.Examples -- E204 (on)
A subtree already bounds the work, unlike a flat query which always scans the whole scheme,
so the prefilter only starts paying once the subtree itself is large. Measured on a 6-level
tree of 99200 nodes: 1189 -> 401 ms and 716677 -> 333755 buffers, identical result sets.
Needs a tree with real depth under the Employee scheme: E203 seeds one, employees arranged as a
reporting tree with ten direct reports per manager. Without depth this example still runs, it
just measures very little.
The differential check here is by COUNT rather than by id set: a tree query over a large
subtree returns tens of thousands of objects and materialising them all would dwarf the
query being measured. Full id-set equality was verified separately in psql.

[ExampleMeta("E204", "PVT prefilter in tree queries", "Trees", ExampleTier.Pro, 200, new string[] { "Sql", "Debug", "Prefilter", "Pro", "Pvt", "Tree" }, RelatedApis = new string[] { "IRedbService.TreeQuery", "IRedbQueryable.ToSqlStringAsync" })]
public class E204_TreePrefilter : ExampleBase

Inheritance

Object→ExampleBase→E204_TreePrefilter

Inherited Members

Methods

RunAsync(IRedbService)

Run the example and return result.

public override Task<ExampleResult> RunAsync(IRedbService redb)