Skip to content

Commit

Permalink
Merge #59598
Browse files Browse the repository at this point in the history
59598: parser: lowercase timespans in extract r=jordanlewis a=jordanlewis

Touches #19965. Confirmed that this (relatively silly) PR gets rid of the allocations in the experiment listed in #19965 (comment)

The `extract` builtin is kind of weird - it is actually supported by the
parser and not an ordinary builtin function that people can call without
parser support. As such, we can normalize its inputs right in the
parser.

The benefit of this is that, later, we are going to unconditionally
ToLower() the string arguments to extract - which costs an allocation.
So we can do this normalization up front to save a bunch of allocations
in queries that run `extract` over a lot of data rows.

Release note (performance improvement): improve the allocation
performance of workloads that use the `EXTRACT` builtin.

Co-authored-by: Jordan Lewis <[email protected]>
  • Loading branch information
craig[bot] and jordanlewis committed Jan 31, 2021
2 parents 8bd46b9 + 8d30d35 commit 3ca562d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -11453,7 +11453,7 @@ array_expr_list:
extract_list:
extract_arg FROM a_expr
{
$$.val = tree.Exprs{tree.NewStrVal($1), $3.expr()}
$$.val = tree.Exprs{tree.NewStrVal(strings.ToLower($1)), $3.expr()}
}
| expr_list
{
Expand Down

0 comments on commit 3ca562d

Please sign in to comment.