To debug the select execution plan for postgres

Asked 1 years ago, Updated 1 years ago, 37 views

Suppose you are throwing a complicated select statement in postgres SQL and you are not getting that performance.

Explaining the select statement explains how postgres performs select, but if you are not sure why such an execution plan was made, how is it debugged?

MySQL has an optimizer trace, so I can somehow understand how the optimizer worked, but I'm asking because I wonder how postgres works.

postgresql

2022-09-29 22:34

1 Answers

According to the PostgreSQL documentation, the statistics used by the planner contain the criteria for determining the execution plan.After reading this, you will be able to determine if the action plan that came out is what you expect.

# However, although I sometimes tune the execution plan, I think I rarely debug it.(Because SQL statements are not statically determined, but are dynamically changed by the number of table data, etc.)
If you want to control the execution plan, you can also use the hint clause (required pg_hint_plan package).


2022-09-29 22:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.