Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agneum/plan-exporter
Query plan exporter for psql
https://github.com/agneum/plan-exporter
explain postgresql psql query-plan
Last synced: 28 days ago
JSON representation
Query plan exporter for psql
- Host: GitHub
- URL: https://github.com/agneum/plan-exporter
- Owner: agneum
- License: mit
- Created: 2020-03-09T17:08:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-08T23:01:27.000Z (over 1 year ago)
- Last Synced: 2024-09-28T18:04:53.585Z (about 1 month ago)
- Topics: explain, postgresql, psql, query-plan
- Language: Go
- Homepage:
- Size: 35.2 KB
- Stars: 51
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Query plan exporter
[![Build Status](https://github.com/agneum/plan-exporter/workflows/build/badge.svg)](https://github.com/agneum/plan-exporter/actions)
[![License](https://img.shields.io/github/license/agneum/plan-exporter)](/LICENSE)
[![Go Report](https://goreportcard.com/badge/github.com/agneum/plan-exporter)](https://goreportcard.com/badge/github.com/agneum/plan-exporter)The utility receives Postgres Query Plans from `psql` and sends them to a visualizer for sharing.
It will compute and highlight the most important information to make them easier to understand.## Installation
#### Precompiled binary (Linux)
It's highly recommended installing a specific version of the `plan-exporter` available on the [releases page](https://github.com/agneum/plan-exporter/releases).To quickly install the tool on Linux, download and decompress the binary, use an example:
```bash
wget https://github.com/agneum/plan-exporter/releases/download/v0.0.5/plan-exporter-0.0.5-linux-amd64.tar.gz
tar -zxvf plan-exporter-0.0.5-linux-amd64.tar.gz
sudo mv plan-exporter-*/plan-exporter /usr/local/bin/
rm -rf ./plan-exporter-*
```#### Build from sources
Version `1.13+` is required.```
git clone [email protected]:agneum/plan-exporter.git
cd plan-exporter
go install github.com/agneum/plan-exporter
```
On default, make install puts the compiled binary in `go/bin`.## Usage
1. Run `psql`
1. Set up output to the query plan exporter:
```bash
postgres=# \o | plan-exporter
```
* You may wish to specify `--target [dalibo|depesz|tensor]` to customize your visualizer
* You may also specify `--post-url ` if you are deploying one of these targets on-premise1. Run explain query:
```bash
postgres=# explain select 1;
postgres=#
QUERY PLAN
------------------------------------------------------
Seq Scan on hypo (cost=0.00..180.00 rows=1 width=0)
Filter: (id = 1)
(2 rows)
Do you want to post this plan to the visualizer?
Send '\qecho Y' to confirm
```1. Confirm of posting the plan to the visualizer: `\qecho Y`
```bash
postgres=# \qecho Y
postgres=# Posting to the visualizer...
```That's it! Receive the link!
```bash
The plan has been posted successfully.
URL: https://explain.depesz.com/s/XXX
postgres=#
```
## Command-Line Options- `--target` - (string, optional) - defines a visualizer to export query plans.
Available targets:
- `depesz` - https://explain.depesz.com [default]
- `dalibo` - https://explain.dalibo.com
- `tensor` - https://explain.tensor.ru
- `--post-url`- (string, optional, default: "") - the absolute URL to which the `` will `POST` to. A good reference would be to look for the `action` param in the `` tag.
- `--auto-confirm` (bool, optional, default: false) - send an execution plan automatically without additional confirmation.
The option allows using `plan-exporter` outside `psql`. For example,
```bash
psql -f my_explain_file.sql | plan-exporter --target=dalibo --auto-confirm
```## Contact Information
Follow the news and releases on [twitter](https://twitter.com/arkartasov).