ランダムデータ(CSV形式)の生成プログラムは,別ページ »で説明している.
次のコマンドで,約 500M バイトのランダムデータ(CSV形式)
./populate.out 7300000 > 500m.csv
ファイルは, 「sudo find -name "postgresql.conf" -print」で探すことができる.
shared_buffers = 1GB work_mem = 1GB max_files_per_process = 1000 effective_cache_size = 4GB
パーソナルに使う場合は,オンライントランザクション処理を行わないので,WAL の機能を実質オフににして運用する可能性がある.
wal_level = minimal archive_mode = off max_wal_senders = 0
エラーメッセージが出ていなければ OK.
sudo pg_ctlcluster 14 main restart sudo pg_ctlcluster 14 main status
次のコマンドを実行.
sudo pg_ctlcluster 14 main stop sudo sync sudo sync sudo sync sudo sync sudo sync sudo sysctl -w vm.drop_caches=3 sudo pg_ctlcluster 14 main start sudo pg_ctlcluster 14 main status echo "drop database if exists testdb;" | sudo -u postgres psql echo "create database testdb;" | sudo -u postgres psql echo "vacuum full;" | sudo -u postgres psql -d testdb
確認のため「select count(*) from T500m;」を実行.date で,処理にかかった時間を確認.
echo "create table T500m(num integer, name text, lat real, lon real, at timestamp);" | sudo -u postgres psql -d testdb date +%H:%M:%S.%3N echo "\copy T500m from '500m.csv' delimiter ','" | sudo -u postgres psql -d testdb date +%H:%M:%S.%3N echo "select count(*) from T500m;" | sudo -u postgres psql -d testdb