Skip to content
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

Add support for scanning multiple spans for a single index. #2293

Merged
merged 1 commit into from
Aug 28, 2015

Conversation

petermattis
Copy link
Collaborator

Index selection now creates multiple independent spans of the index that
must be scanned. Multiple spans are created for expressions like "a
IN (1, 2, 3)" and "a = 1 OR a = 2 or a = 3" (these are equivalent).

Fixes #2140.
See #2142.

@@ -54,7 +54,6 @@ func moveMoney(db *sql.DB) {
log.Fatal(err)
}
startTime := time.Now()
// Query is very slow and will be fixed by https://github.com/cockroachdb/cockroach/issues/2140
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query is usually no longer very slow, but I still sometimes see log messages like:

I0828 15:07:06.299984 34037 examples/sql_bank/main.go:61 SELECT id, balance FROM accounts WHERE id IN (130, 204) took 3.059484793s

@tamird
Copy link
Contributor

tamird commented Aug 28, 2015

LGTM with test coverage of more interesting index constraints

@petermattis petermattis force-pushed the pmattis/sql-scan-spans branch from eea5235 to 91631eb Compare August 28, 2015 20:04
@@ -92,6 +101,13 @@ EXPLAIN (DEBUG) SELECT * FROM t WHERE a = 1 AND b > 'b'
0 /t/primary/1/'c' NULL true

query ITTB
EXPLAIN (DEBUG) SELECT * FROM t WHERE a > 1 AND b > 'ba'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this a > 2? currently this is just a table scan, i think

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i stand corrected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an index scan in the sense that it constructed a key using the constraint a > 1. I can see this from debug info at log.V(2). If I changed this to a > 2 no keys would be scanned.

Index selection now creates multiple independent spans of the index that
must be scanned. Multiple spans are created for expressions like "a
IN (1, 2, 3)" and "a = 1 OR a = 2 or a = 3" (these are equivalent).

Fixes #2140.
See #2142.
@petermattis petermattis force-pushed the pmattis/sql-scan-spans branch from 91631eb to ba35f7b Compare August 28, 2015 20:28
petermattis added a commit that referenced this pull request Aug 28, 2015
Add support for scanning multiple spans for a single index.
@petermattis petermattis merged commit 5289274 into master Aug 28, 2015
@petermattis petermattis deleted the pmattis/sql-scan-spans branch August 28, 2015 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants