cockroachdb / cockroachdb/cockroach

opt: tighten constraints on range scans of hash-sharded indexes to only necessary buckets

Open
#147,188 2 comments 0 reactions 0 assignees View on GitHub
A-hash-sharding A-sql-optimizer C-performance E-quick-win T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Consider the following range query on a table with a hash-sharded primary index:

```sql
CREATE TABLE a (a INT NOT NULL, PRIMARY KEY (a) USING HASH WITH (bucket_count = 16));
EXPLAIN (VERBOSE) SELECT * FROM a WHERE a >=1 AND a < 5;
```

The only possible buckets that could contain rows are:
* a=1: bucket 11
* a=2: bucket 6
* a=3: bucket 13
* a=4: bucket 2

And yet we build a plan that scans all 16 buckets, instead of just the 4 that cover this range. It would be nice to only scan the necessary buckets.

Jira issue: CRDB-50914

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.