cockroachdb / cockroachdb/cockroach

sql/hints: failed hint causes prepared memo to always be invalidated

Open
#167,322 3 comments 0 reactions 0 assignees View on GitHub
A-plan-management A-statement-hint C-performance T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

After preparing a memo with an injected statement hint fails, we set `usingHintInjection` [to false](https://github.com/cockroachdb/cockroach/blob/2d7256aebf3a9af6551df5ec35cb3f9a8e3100c2/pkg/sql/plan_opt.go#L71) and re-plan, caching the result. However, when the prepared memo is executed, we check for staleness with `usingHintInjection` [set to true,](https://github.com/cockroachdb/cockroach/blob/2d7256aebf3a9af6551df5ec35cb3f9a8e3100c2/pkg/sql/plan_opt.go#L315) which results in the memo being invalidated. We should either reuse the memo without hints, or not re-plan during prepare, since otherwise we're doing extra work for no reason.

Jira issue: CRDB-62381

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.