New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-2.1: distsql: eagerly evaluate constant expressions #31091

Merged
merged 1 commit into from Oct 8, 2018

Conversation

Projects
None yet
3 participants
@solongordon
Contributor

solongordon commented Oct 8, 2018

Backport 1/1 commits from #30216.

/cc @cockroachdb/release


exprHelper now normalizes its expression upon initialization. This
causes constant subexpressions to be evaluated up front, rather than re-
evaluating them every time eval or evalFilter is called, and thus
avoids a hefty per-row cost for expensive expressions. For example, the
SELECT query in the example below now returns in ~100ms rather than
~10s.

CREATE TABLE t (x int[]);
INSERT INTO t SELECT array[x] FROM generate_series(1, 10000) AS x;
SELECT * FROM t WHERE x = (SELECT array_agg(generate_series(1,10000)));

This also uncovered a bug in the normalizer where NOT IN () returned
false rather than true.

Fixes #30167

Release note: None

distsql: eagerly evaluate constant expressions
exprHelper now evaluates constant subexpressions upon initialization,
rather than re-evaluating them every time `eval` or `evalFilter` is
called, and thus avoids a hefty per-row cost for expensive expressions.
For example, the SELECT query in the example below now returns in ~30ms
rather than ~10s.

```
CREATE TABLE t (x int[]);
INSERT INTO t SELECT array[x] FROM generate_series(1, 10000) AS x;
SELECT * FROM t WHERE x = (SELECT array_agg(generate_series(1,10000)));
```

Fixes #30167

Release note: None

@solongordon solongordon requested a review from jordanlewis Oct 8, 2018

@solongordon solongordon requested review from cockroachdb/distsql-prs as code owners Oct 8, 2018

@cockroach-teamcity

This comment has been minimized.

Show comment
Hide comment
@cockroach-teamcity

cockroach-teamcity Oct 8, 2018

Member

This change is Reviewable

Member

cockroach-teamcity commented Oct 8, 2018

This change is Reviewable

@solongordon solongordon merged commit ad11a25 into cockroachdb:release-2.1 Oct 8, 2018

2 checks passed

GitHub CI (Cockroach) TeamCity build finished
Details
license/cla Contributor License Agreement is signed.
Details

@solongordon solongordon deleted the solongordon:backport2.1-30216 branch Oct 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment