You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(optimizer): speed up qualify by ~24% and optimize by ~17% (#7724)
- Add Expression.meta_get(key, default), a non-allocating meta read: the
meta property allocates {} on first read, so hot per-node read paths
(normalize_identifiers' prune, simplify's FINAL checks) were allocating
a dict on every AST node and slowing every subsequent copy(). Convert
all read-only .meta.get(...) sites; writes still go through meta.
- Scope._collect: a single tuple-isinstance gate (COLLECTIBLE_TYPES) lets
non-collectible nodes skip the classification chain, paid 3x per query
(qualify_tables, qualify_columns, validate_qualify_columns).
- walk_in_scope: only CTE/Query nodes can start child scopes, so one
isinstance gate replaces up to 4 checks + 2 parent loads per node.
- Scope.local_columns: identity-based set instead of structural-equality
set of column nodes.
- parse_identifier: skip the tokenizer/parser round-trip for names
matching SAFE_IDENTIFIER_RE (provably identical output).
- _expand_using: early-exit for scopes with no joins / no USING joins,
preserving the missing-source validation.
- quote_identifiers: direct walk over Identifier nodes instead of
transform(), which only does replacement bookkeeping here.
Qualified SQL is byte-identical on all TPC-H/TPC-DS fixture queries.
Pure Python and mypyc release builds both pass the full suite.
0 commit comments