<commit_before># docker-postgresplus


## Overview
PostgreSQL playground running on Docker with logs presented in Kibana dashboard and Pgadmin webinterface.

## Usage
Install Docker. Clone this repo to your local machine. Run docker-compose: 
```bash
docker-compose up
```

### Open pgAdmin webinterface
```bash
http://localhost:5050
```
Database, username and password: postgres

### Connect to Postgres container
     docker exec -it dockerpostgresplus_postgres_1 sh
     sudo -s

### Download and unzip test database (in the container)
     wget https://s3.amazonaws.com/assets.datacamp.com/course/sql/dvdrental.zip; unzip dvdrental.zip

### Create database (psql)
     su postgres
     psql
     CREATE DATABASE dvdrental;
     exit

### Load database using pg_restore
     pg_restore -U postgres -d dvdrental dvdrental.tar

### Run 1000 queries
     yes "select * from public.film_actor;" | head -n 1000 | parallel "psql -U postgres -d dvdrental -c {1}"

## Pgbench
     psql> CREATE DATABASE pgbenchdb;
     pgbench -i -s 50 pgbenchdb
     pgbench -c 10 -j 2 -t 1000 pgbenchdb

### Import dashboard
To make sure all fields exist prior to importing the Kibana dashboard, run pgbench first.


### Useful commands
```bash
# Check CPU consumption<commit_msg>Change name of database to Sakila<commit_after># docker-postgresplus


## Overview
PostgreSQL playground running on Docker with logs presented in Kibana dashboard and Pgadmin webinterface.

## Usage
Install Docker. Clone this repo to your local machine. Run docker-compose: 
```bash
docker-compose up
```

### Open pgAdmin webinterface
```bash
http://localhost:5050
```
Database, username and password: postgres

### Connect to Postgres container
     docker exec -it dockerpostgresplus_postgres_1 sh
     sudo -s

### Download and unzip test database (in the container)
     wget https://s3.amazonaws.com/assets.datacamp.com/course/sql/dvdrental.zip; unzip dvdrental.zip

### Create database (psql)
     su postgres
     psql
     CREATE DATABASE sakila;
     exit

### Load database using pg_restore
     pg_restore -U postgres -d sakila dvdrental.tar

### Run 1000 queries
     yes "select * from public.film_actor;" | head -n 1000 | parallel "psql -U postgres -d sakila -c {1}"

## Pgbench
     psql> CREATE DATABASE pgbenchdb;
     pgbench -i -s 50 pgbenchdb
     pgbench -c 10 -j 2 -t 1000 pgbenchdb

### Import dashboard
To make sure all fields exist prior to importing the Kibana dashboard, run pgbench first.


### Useful commands
```bash
# Check CPU consumption
{'fraction_non_alphanumeric': 0.08771236665349665, 'fraction_numerical': 0.018964836033188465, 'mean_word_length': 3.6373626373626373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '154157', 'n_tokens_mistral': 866, 'n_tokens_neox': 769, 'n_words': 292}