Skip to content

sql: use the same determination for optimizations during prepare as exec #26958

@knz

Description

@knz

Logical plans in CockroachDB are created on 3 different paths:

  • the regular "simply query" execution path in (connExecutor) dispatchToExecutionEngine()
  • PREPARE statements in SQL and pgwire prepare messages, via (connExecutor) prepare()
  • DO NOTHING mutations (parallel statements)

The optimizer cluster setting currently only works with the 1st code path.

Arguably we are not supporting the 3rd because the optimizer doesn't deal with mutations yet.

However the 2nd is a problem since most applications use prepared queries: queries using correlation appear currently broken with the prepare protocol despite the setting "optimizer is enabled".

The solution is to factor the choice of planning engine across (connExecutor) dispatchToExecutionEngine() and (connExecutor) prepare().

cc @justinj

Metadata

Metadata

Assignees

Labels

A-sql-optimizerSQL logical planning and optimizations.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions