-
Notifications
You must be signed in to change notification settings - Fork 4.1k
opt: optimizer ignores NO_INDEX_JOIN in some cases #85841
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Description
Describe the problem
In some cases, the optimizer may ignore a NO_INDEX_JOIN hint and create a query plan with an index join.
To Reproduce
This can be reproduced with ./cockroach demo:
> CREATE TABLE defg (
d INT,
e INT,
f INT,
g INT,
INDEX dd (d),
INDEX dfg (d, f, g),
INDEX df (d, f)
);
> explain SELECT d, f, e FROM defg@{NO_INDEX_JOIN} ORDER BY d, f, e LIMIT 10;
info
---------------------------------------------------
distribution: local
vectorized: true
• top-k
│ order: +d,+f,+e
│ k: 10
│
└── • index join
│ table: defg@defg_pkey
│
└── • scan
missing stats
table: defg@df
spans: FULL SCAN (SOFT LIMIT)
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON defg (d, f, e);
(18 rows)
Expected behavior
If NO_INDEX_JOIN is specified, the optimizer should choose a plan that does not include an index join.
Environment:
- CockroachDB 22.1
- Server OS: MacOS
- Client app
cockroach demo
Jira issue: CRDB-18465
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Type
Projects
Status
Done