The greedy literal-ordering planner, shared by the magic-set rewrite and the executors. Source:
plan.rs.Sources: SPEC-007 Sophia Query Language §6.1. code:
plan.rs
access_columnssays which columns of each base relation have an access path on every backend (for examplerefs: both columns, throughrefs_ofanddependants).orderschedules filters as soon as their variables are bound, then prefers base literals that can use an access path, then local literals with bound arguments, and full scans last. Variables that occur only inside one negated literal are existential.widemarks lookups that return a large share of a relation: by kind, and by collection. They rank after local literals (SPEC-007 §6.1, measured on set.mm).name_prefix(B-014): a positivename(p, _)with neither column bound and astartswith(p, s)in the body whosesis bound can be read as a prefix range. It then ranks like a wide lookup.check_safeusesorderto report a variable that no literal binds.