1
0
mirror of https://gitlab.com/depesz/explain.depesz.com.git synced 2024-11-24 08:42:27 +02:00
Webpage for showing easier to read version of PostgreSQL explains
Go to file
2022-11-12 10:27:49 +01:00
docker Fix docker dependency 2022-09-14 14:52:52 -04:00
ext Beautify queries, and hide bogus "actual" info 2020-11-05 15:38:16 +01:00
layout new version of explain.depesz.com, by metys - llewandowski.pl 2011-03-10 15:19:34 +00:00
lib use Pg::SQL::PrettyPrinter by default 2022-08-31 12:44:27 +02:00
public hints are not new anymore 2022-10-11 11:49:39 +02:00
scripts Dont use cursor for getting plans 2022-03-07 13:15:51 +01:00
sql move partitions to public schema 2021-11-23 13:16:20 +01:00
t add cpanfile and more req-tests 2019-09-03 15:56:34 +02:00
templates add ... to suggest that more options are handled 2022-11-12 10:27:49 +01:00
.dockerignore Update docker files to develop in non-native env 2022-07-12 15:08:48 +01:00
.gitattributes Give up on assuming CSV encoding 2022-07-14 10:35:46 +01:00
.gitignore Ignore vscode files 2022-06-12 15:16:33 +02:00
.gitmodules Beautify queries, and hide bogus "actual" info 2020-11-05 15:38:16 +01:00
cpanfile use Pg::SQL::PrettyPrinter by default 2022-08-31 12:44:27 +02:00
explain-json-notes.txt Editorialization of last merge 2014-10-31 15:55:59 +01:00
explain.development.json Display plan settings 2021-07-18 20:00:49 +02:00
explain.json use Pg::SQL::PrettyPrinter by default 2022-08-31 12:44:27 +02:00
explain.pl server runs, not fully tested 2014-10-31 06:04:52 -07:00
explain.pp grant use of schema plans to db user 2017-04-24 14:06:51 +03:00
hypnotoad.conf make the config for production 2011-03-15 10:59:46 +00:00
LICENSE Update year in copyright 2020-11-05 16:50:16 +01:00
README.md add information about modules in git clone 2022-06-21 18:32:53 +02:00
run.dev.sh logs go to screen, not to file 2022-11-12 09:56:20 +01:00
vagrant_bootstrap.sh Rearrange steps, make Docker-ization simpler 2018-08-26 10:58:25 -07:00
Vagrantfile Make Vagrantfile usable for non-Puppet users 2018-08-26 10:58:24 -07:00

explain.depesz.com

Setup

There are three ways to install your own copy:

  1. Using Vagrant [ VirtualBox machine, fully automated ]
  2. Calling puppet apply
  3. Manually

First get the source code:

git clone --recurse-submodules https://gitlab.com/depesz/explain.depesz.com.git

Vagrant setup

WARNING: The first call of vagrant up fetches a ~400MB vbox image from the Internet.

  1. Call vagrant up

Point your browser on http://192.168.44.55 (or use /etc/hosts entry explain.depesz.loc)

Puppet setup

  1. Install puppet on your machine, e.g. Debian installation described here.
  2. Open explain.pp and fix line 5 with correct project dir value
  3. Call sudo puppet apply --logdest console explain.pp on your working copy directory.

Docker Compose setup

NOTE This setup should be considered for quick analysis purposes only - while docker-compose does keep DBs around from run to run, don't rely on it to store your history long term.

cd docker
docker-compose up --build

Manual setup

1) Mojolicious

You have to have Mojolicious installed on your server. Mojolicious is a web framework for Perl. http://mojolicio.us/

Installation can be accomplished with one command line:

curl -L cpanmin.us | perl - -n Mojolicious

See the Installation section at http://mojolicio.us/ for details.

2) Perl Dependencies:

You will need the following packages installed in your version of Perl:

DBD::Pg
DBI
Date::Simple
Digest::MD5
Email::Sender::Simple
Email::Simple
Email::Valid
Mojolicious
Number::Bytes::Human
Pg::Explain

Install the above packages using cpan then -i Date::Simple, -i Email::Sender, &etc.

Note that in case of most current Linux distributions, you can install most of these from binary package repositories. For example, in case of Ubuntu and Debian, you can:

apt-get install libmojolicious-perl \
                libemail-sender-perl \
                libdate-simple-perl \
                libemail-valid-perl \
                libxml-simple-perl  \
                libdbd-pg-perl

And then only add missing modules via CPAN.

Alternatively, if you have cpanm program you should be able to install all dependencies using:

cpanm --installdeps .

3) PostgreSQL

You'll need to have PostgreSQL installed in order to record all the explain plans into history. Consult the PostgreSQL Wiki for more information

3A) Create a new database explain

This will be were the explain server will store the users and plans tables in the default schema public.

3B) Run SQL scripts

Log in to the explain database and execute the SQL scripts located in this project's sql directory. You should start with create.sql:

\i create.sql

And then load all patch-NNN.sql files in their numerical order:

\i patch-001.sql
\i patch-002.sql
...

The create.sql will create tables in the explain database public schema, i.e. plans and users.

3C) Create a user role

I use explaind [explain daemon], for example. Remember to provide it a password and then configure the explain.json file to reflect this new role and password.

CREATE USER explaind WITH PASSWORD 'explain';

3D) Grant all rights to the tables in explain to your role:

GRANT ALL ON plans, users TO explaind;

3E) modify pg_hba.conf so that it has the server as "127.0.0.1"

local   all             all             127.0.0.1               trust

If you do not want to alter pg_hba.conf, then you might be able to modify the explain.json.dsn setting to specify the name of the value in the server column from your pg_hba.conf file, e.g. "localhost". This alternative approach has not been tested. It would be desirable to install this project with the minimal amount of configuration changes, so I encourage someone to come up with a solution that removes this step "E".

4) Configure explain.json

Make sure you have the correct values for your database connection. See companion documentation file explain-json-notes.txt

5) Shell

The explain server runs on port 3000. Make sure port 3000 is available and not in use by another process. You may have to specify a different port (e.g. 3200). I do not know where you do that, probably in Mojolicious.

In the trunk directory for this project, run in a shell:

 ./explain.pl daemon

6) Browser

Then access the web page http://localhost:3000 When you access the web page, remember to login and create an account for yourself so that your explain plans will be associated with your account.