cockroachdb / cockroachdb/cockroach

sql: not applying plangrams after placeholder fast path

Open
#172,462 0 comments 0 reactions 1 assignee Claimed by @michae2 View on GitHub
A-plan-management A-statement-hint branch-release-26.3 C-bug O-qa T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

If a statement qualifies for the placeholder fast path, then we don't apply a PlanGram during optimization, even if there is one for the statement. For example:

```sql
CREATE TABLE xy (x INT PRIMARY KEY, y INT);

EXPLAIN (VERBOSE) SELECT * FROM xy WHERE x = 10;
-- point-lookup in xy_pkey

SELECT information_schema.crdb_pin_plan_gram(
'SELECT * FROM xy WHERE x = _',
'root: (Select (Scan));'
);

EXPLAIN (VERBOSE) SELECT * FROM xy WHERE x = 10;
-- filter over a full scan of xy_pkey

PREPARE p AS SELECT * FROM xy WHERE x = $1;
EXPLAIN ANALYZE (VERBOSE) EXECUTE p(10);
-- but this plan still uses a point lookup, doesn't respect the pinned plan
```

Jira issue: CRDB-65700

Epic: CRDB-66266

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.