The official postgres:18 Docker 514 image gives the WSL2 6 host an exact, disposable server (Docker came in WSL2, Ubuntu and Docker). These commands, condensed from demos/ch04/scripts/pg_up.sh and load/load.sh, start it and load the CSV export of the sample data:
docker run -d --name l2-pg --shm-size=1g -e POSTGRES_PASSWORD=booknest \
-e POSTGRES_DB=booknest -p 32543:5432 postgres:18 >/dev/null
until docker exec l2-pg pg_isready -h localhost -U postgres -q; do sleep 1; done
PSQL="docker exec -i l2-pg psql -U postgres -d booknest -X -q"
$PSQL < load/schema.sql
for t in books customers orders order_items; do
$PSQL -c "COPY $t FROM STDIN (FORMAT csv, HEADER true)" < csv-out/$t.csv
done
$PSQL -c "VACUUM ANALYZE"
$PSQL -At -c "SHOW server_version"Output
18.6 (Debian 18.6-1.pgdg13+2)
COPY ... FROM STDIN streams each file into the server, the fastest bulk load, and VACUUM ANALYZE gathers the planner's statistics. --shm-size=1g matters because parallel workers exchange data through /dev/shm, which Docker limits to 64 MB, too little for a large parallel hash join. Clients on the host connect to localhost:32543. Raise work_mem (4 MB per sort or hash by default) per analytical session, not server-wide.