parent
3132a39816
commit
e69d9b4238
3 changed files with 23 additions and 38 deletions
File diff suppressed because one or more lines are too long
@ -1,37 +0,0 @@ |
|||||||
# Pev - A PostgreSQL Explain Visualizer |
|
||||||
|
|
||||||
As you delve deeper into query analysis, it becomes important to understand and visualize the execution plans of your queries. One highly recommended tool for this purpose is `pev`, short for **PostgreSQL Explain Visualizer**. |
|
||||||
|
|
||||||
Pev is an open-source, web-based platform that takes the output of the `EXPLAIN` or `EXPLAIN ANALYZE` command and turns it into an intuitive and interactive graphical representation, allowing you to better understand and optimize query performance. |
|
||||||
|
|
||||||
## Features |
|
||||||
- Color-coded nodes for intuitive understanding of scan types and costs |
|
||||||
- Detailed information on each node with metrics like duration, loops, cost, and rows |
|
||||||
- Zoom in and out for easy navigation through complex plans |
|
||||||
- Supports various output formats (JSON, YAML, and XML) |
|
||||||
|
|
||||||
## Using Pev |
|
||||||
|
|
||||||
In order to use Pev, follow these steps: |
|
||||||
|
|
||||||
- Run your query with the `EXPLAIN` or `EXPLAIN ANALYZE` command in PostgreSQL to generate the query execution plan. |
|
||||||
|
|
||||||
``` |
|
||||||
EXPLAIN (FORMAT JSON) SELECT * FROM my_table WHERE id = 1; |
|
||||||
``` |
|
||||||
|
|
||||||
- Copy the resulting JSON output. |
|
||||||
|
|
||||||
- Head to the [Pev online visualizer](https://tatiyants.com/pev/) (or a [local instance](https://github.com/AlexTatiyants/pev) if you prefer) and paste the JSON output into the text box. |
|
||||||
|
|
||||||
- Pev will automatically generate an interactive, graphical representation of your query's execution plan to better comprehend the query's cost breakdown and any potential bottlenecks. |
|
||||||
|
|
||||||
## Example: |
|
||||||
|
|
||||||
Here's a sample of how Pev represents an execution plan. Note the easily distinguishable scan types with color-coding, and how the tooltips provide additional details when hovering over nodes. |
|
||||||
|
|
||||||
![Pev Example](https://tatiyants.com/pev/img/tooltip.png) |
|
||||||
|
|
||||||
## Summary |
|
||||||
|
|
||||||
In conclusion, Pev is an essential tool for any PostgreSQL developer looking to analyze and optimize their queries. By providing a clear visual representation of query execution plans, it enables you to quickly spot areas of improvement and ensure the overall efficiency of your database operations. |
|
@ -0,0 +1,22 @@ |
|||||||
|
# PEV2 |
||||||
|
|
||||||
|
`pev2`, or *Postgres Explain Visualizer v2*, is an open-source tool designed to make query analysis with PostgreSQL easier and more understandable. By providing a visual representation of the `EXPLAIN ANALYZE` output, `pev2` simplifies query optimization by displaying the query plan and execution metrics in a readable structure. In this section, we cover the key features of `pev2` and explore how it assists in query analysis. |
||||||
|
|
||||||
|
* **Visual Representation**: `pev2` converts the raw text output of an `EXPLAIN ANALYZE` query into an interactive and color-coded tree structure that is easy to understand at a glance. |
||||||
|
|
||||||
|
* **Query Plan Metrics**: The tool provides useful execution metrics, such as the query's total execution time, processing steps, and related node costs. |
||||||
|
|
||||||
|
* **Powerful Interactivity**: Hovering over specific nodes in the visual representation displays additional information, like the time spent on a specific step or the number of rows processed. |
||||||
|
|
||||||
|
* **Indented JSON Support**: `pev2` supports indented JSON parsing, making it easier to read and understand the plan for large and complex queries. |
||||||
|
|
||||||
|
* **Save and Share Plans**: The tool allows you to save your query plans as a URL, facilitating easy sharing with your colleagues. |
||||||
|
|
||||||
|
To use `pev2`, follow these steps: |
||||||
|
1. Run your `EXPLAIN ANALYZE` query in your preferred PostgreSQL client. |
||||||
|
2. Copy the output text. |
||||||
|
3. Visit [https://explain.depesz.com/](https://explain.depesz.com/). |
||||||
|
4. Paste the copied output in the text box and click "Explain." |
||||||
|
5. Explore the visual representation of the query plan and analyze your query's performance. |
||||||
|
|
||||||
|
Now that you are familiar with `pev2`, use it to better understand and optimize your PostgreSQL queries. Remember, fine-tuning your queries can significantly improve performance and ensure a seamless experience for end-users. Happy optimizing! |
Loading…
Reference in new issue