Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document generic query plans #18753

Merged
merged 7 commits into from
Aug 8, 2024
Merged

document generic query plans #18753

merged 7 commits into from
Aug 8, 2024

Conversation

taroface
Copy link
Contributor

@taroface taroface commented Jul 19, 2024

DOC-10470

  • Document generic query plans.
  • Expand descriptions of custom plans and plan cache.
  • Add session setting.
  • Add new EXPLAIN field.

Copy link

github-actions bot commented Jul 19, 2024

Copy link

netlify bot commented Jul 19, 2024

Deploy Preview for cockroachdb-interactivetutorials-docs canceled.

Name Link
🔨 Latest commit fad6076
🔍 Latest deploy log https://app.netlify.com/sites/cockroachdb-interactivetutorials-docs/deploys/66b518b3e26850000895cb07

Copy link

netlify bot commented Jul 19, 2024

Deploy Preview for cockroachdb-api-docs canceled.

Name Link
🔨 Latest commit fad6076
🔍 Latest deploy log https://app.netlify.com/sites/cockroachdb-api-docs/deploys/66b518b3353d530008a1ec59

Copy link

netlify bot commented Jul 19, 2024

Netlify Preview

Name Link
🔨 Latest commit fad6076
🔍 Latest deploy log https://app.netlify.com/sites/cockroachdb-docs/deploys/66b518b37c16a90009c00bc1
😎 Deploy Preview https://deploy-preview-18753--cockroachdb-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@taroface taroface changed the title [wip] document generic query plans document generic query plans Jul 29, 2024
@taroface taroface requested review from mgartner and dikshant July 29, 2024 18:54
Copy link
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! I left a few suggestions inline.

We might also want to cal lout that you'll only get the benefits of generic query plans if you're using prepared statements, either with an explicit PREPARE statement, or with the extended query protocol (which many ORMs and clients will use automaticall): https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY

But we don't have any documentation on the extended query protocol, that I can find.

src/current/v24.2/cost-based-optimizer.md Outdated Show resolved Hide resolved
src/current/v24.2/cost-based-optimizer.md Outdated Show resolved Hide resolved
@taroface
Copy link
Contributor Author

taroface commented Aug 5, 2024

Very nice! I left a few suggestions inline.

We might also want to cal lout that you'll only get the benefits of generic query plans if you're using prepared statements, either with an explicit PREPARE statement, or with the extended query protocol (which many ORMs and clients will use automaticall): https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY

But we don't have any documentation on the extended query protocol, that I can find.

@mgartner TFTR! Is it a significant gap that we don't document the extended query protocol? Or would its meaning be clear enough if I say, e.g., ... the extended query protocol that many ORMs and clients will use automatically?

EDIT: I sort of wrote around this.

@taroface taroface force-pushed the generic-query-plans branch 2 times, most recently from 7ea49fd to 9be05ca Compare August 6, 2024 17:08
Copy link
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Left a few more comments.

I do think we should call out that generic query plans come with a trade-off: the plans produced may be less efficient than a custom plan. For that reason, we should urge users to use plan_cache_mode=auto instead of force_generic_plan because under this setting the database should avoid bad generic query plans and fallback to custom plans.

src/current/v24.2/cost-based-optimizer.md Outdated Show resolved Hide resolved
src/current/v24.2/cost-based-optimizer.md Outdated Show resolved Hide resolved
@taroface
Copy link
Contributor Author

taroface commented Aug 7, 2024

@mgartner I made some adjustments based on your feedback - PTAL.

Copy link
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! as discussed in slack, we may want to link to the guidance on reorder_joins_limit where many-join queries are mentioned

@taroface taroface requested a review from florence-crl August 8, 2024 16:13
Copy link
Contributor

@florence-crl florence-crl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, non-blocking nits

src/current/_includes/v24.2/misc/session-vars.md Outdated Show resolved Hide resolved
src/current/v24.2/cost-based-optimizer.md Outdated Show resolved Hide resolved
src/current/v24.2/cost-based-optimizer.md Outdated Show resolved Hide resolved
@taroface taroface enabled auto-merge (squash) August 8, 2024 19:00
@taroface taroface disabled auto-merge August 8, 2024 19:02
@taroface taroface force-pushed the generic-query-plans branch from 5322c13 to fad6076 Compare August 8, 2024 19:12
@taroface taroface enabled auto-merge (squash) August 8, 2024 19:13
@taroface taroface merged commit d65f868 into main Aug 8, 2024
7 checks passed
@taroface taroface deleted the generic-query-plans branch August 8, 2024 19:16
mdlinville pushed a commit that referenced this pull request Aug 9, 2024
* document generic query plans

---------

Co-authored-by: Florence Morris <[email protected]>
mdlinville pushed a commit that referenced this pull request Aug 12, 2024
* document generic query plans

---------

Co-authored-by: Florence Morris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants