Welcome to this playground. You can test all tips of 10 tips to optimize PostgreSQL queries in your Django project using this repo.
To run this playground, you'll need
- Install virtualenv
You may need to install graphviz before
pipenv install -d
- Setup your environment
Copy the example env file
cp .env.example .env
Edit .env
by setting a PostgreSQL password and a Django Secret Key.
- Activate your environment
pipenv shell
- Start your PostgreSQL container
docker compose up -d
- Open a notebook
./manage.py shell_plus --notebook
You are now ready to start ;)
mkdir -p db_dump
pg_dump -h localhost -p $DATABASE_PORT -Fd $DATABASE_NAME -U $DATABASE_USER -Z0 -j 10 -f dumpdir
tar -cf - dumpdir | pigz > db_dump/dumpdir.tar.gz
cd db_dump
split -n 4 dumpdir.tar.gz dbdump --additional-suffix=.db.part
cat db_dump/dbdump*.db.part > db_dump/dumpdir.tar.gz
mkdir -p dumpdir
pigz -dc db_dump/dumpdir.tar.gz | tar -C dumpdir --strip-components 1 -xf -
pg_restore -j 10 -Fd -O -h localhost -p $DATABASE_PORT -U $DATABASE_USER -d $DATABASE_NAME dumpdir