Skip to content

feat: Improve EXPLAIN support for MySQL and PostgreSQL#2165

Open
seladb wants to merge 7 commits intotortoise:developfrom
seladb:improved-explain
Open

feat: Improve EXPLAIN support for MySQL and PostgreSQL#2165
seladb wants to merge 7 commits intotortoise:developfrom
seladb:improved-explain

Conversation

@seladb
Copy link
Copy Markdown
Contributor

@seladb seladb commented Apr 3, 2026

Improve EXPLAIN support - add output format and explain options for supported databases (PostgreSQL and MySQL)

Description

  • MySQL executor: Added execute_explain() with support for FORMAT (JSON, TRADITIONAL, TREE) and ANALYZE options
  • PostgreSQL executor: Enhanced with multiple output formats (TEXT, JSON, XML, YAML) and options (ANALYZE, BUFFERS, COSTS, MEMORY, SETTINGS, SERIALIZE, SUMMARY, TIMING, VERBOSE, WAL)
  • Base executor: Added proper error handling for unsupported formats/options
  • QuerySet API: Updated explain() method to accept output_fmt and additional options

Motivation and Context

Previously, the explain() method had limited functionality. This adds comprehensive EXPLAIN support for MySQL and PostgreSQL, allowing users to get detailed query execution plans in multiple formats and with various options.

How Has This Been Tested?

Added the following tests:

  • Tests for MySQL EXPLAIN (JSON, traditional, tree formats, analyze)
  • Tests for PostgreSQL EXPLAIN (various formats and all options)
  • Tests for unsupported formats/options error handling

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Implement execute_explain() in mysql/executor.py with support for
  FORMAT (JSON, TRADITIONAL, TREE) and ANALYZE options
- Update base_executor to raise proper errors for unsupported formats/options
- Add comprehensive tests for explain() in test_postgres.py, test_mysql.py,
  and test_explain.py covering various formats and options
- Add error handling for unsupported options in MySQL executor
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 3, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing seladb:improved-explain (787f8d8) with develop (2df46d0)

Open in CodSpeed

@seladb
Copy link
Copy Markdown
Contributor Author

seladb commented Apr 3, 2026

@abondar I'm not sure why MSSQL tests fail randomly, but it's not related to the changes in this PR

@seladb seladb marked this pull request as ready for review April 3, 2026 08:06
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.

1 participant