A helper extension to collect query parsing, planning & execution data and send it to a TreePaint Client via a TCP Socket.
- Go to
contribfolder of your copy of PostgreSQL source code. - Clone this repository into
contribfolder:git clone https://github.com/REUSS-dev/pg_treepaint cdinto pg_treepaintmake && make install
- Load extension using
LOAD 'pg_treepaint'; - Optionally add
pg_treepaintto your postgresql.conf'sshared_preload_librariesso it loads automatically. - Use EXPLAIN option
tp_planto send collected query data to a TreePaint Client.
As in:EXPLAIN (tp_plan) SELECT * FROM pg_extension;
Please note that current version of an extension is not ready for production use and EXPLAIN data payload is unencrypted at the moment.
Use only on localhost and/or in controlled environments.
For your plan data to reach TreePaint Client, you must supply extension with a valid IP and port that TreePaint Client listens at.
There are 3 possible sources for ip and port of endpoint TreePaint Client and 3 levels of priority respectively.
| Priority | Source | IP parameter name | Port parameter name | Comment |
|---|---|---|---|---|
| 1 | EXPLAIN options | tp_ip | tp_port | Example: EXPLAIN (tp_plan, tp_ip '127.0.0.1', tp_port 1111) |
| 2 | GUC parameters | pg_treepaint.ip | pg_treepaint.port | Define your IP and port in postgresql.conf using these parameters to avoid specifying tp_ip & tp_port every time. |
| 3 | Hardcoded defaults | 127.0.0.1 | 4523 | These are values hardcoded in pg_treepaint.c and used by default if no ip or port defined elsewhere. |
Note
If you have TreePaint Client open, you will see IP:PORT pair that it listens to in top-right corner.
If you are seeing "TCP Inactive" instead, click the TCP Applet to enable TCP Client.You can set TCP client to auto-start in TreePaint Client's conf.lua file by changing CLIENT_AUTOSTART from false to true.
