I want to have a load test on my postgresql database named dvdrental.While using postgres default parameters in postgresql.conf file , my database performance is pretty better than other situations.My node is about 8GB of RAM and 4 cpu cores. The query I used for pgbench is in a file named sql_query.sql :
SELECT
account.first_name,
s1.time as time,
random() * (100-0) + 0 AS cpu_usage,
random() * (30-26) + 26 * 1024 AS average_mhs,
random() * (90-50) + 50 AS temperature,
random() * (100-0) + 0 AS fan
FROM generate_series(
'2018-10-14',
'2021-10-15',
INTERVAL '1 day') AS s1(time)
CROSS JOIN(
SELECT
account_id,
first_name,
last_name
FROM account limit 100
) account
ORDER BY
account.account_id,
s1.time;
While account is a table in dvdrental database with account_id , first_name and last_name columns. So the command I use for pgbench is :
pgbench -f sql_query.sql -n -r -c 50 -T 400 -j 4 dvdrental
The result I get is:
pgbench (14.11 (Ubuntu 14.11-0ubuntu0.22.04.1))
transaction type: sql_query.sql
scaling factor: 1
query mode: prepared
number of clients: 50
number of threads: 4
duration: 400 s
number of transactions actually processed: 3038
latency average = 6497.161 ms
initial connection time = 79.758 ms
tps = 7.695669 (without initial connection time)
statement latencies in milliseconds:
6210.604 SELECT
then I tried to change parameters to :
shared_buffers = "2GB",
effective_cache_size = "6GB",
maintenance_work_mem = "512MB",
checkpoint_completion_target = 0.9,
wal_buffers = 16MB,
default_statistics_target = 100,
random_page_cost = 1.1,
effective_io_concurrency = 200,
work_mem = "20971kB",
huge_pages = off,
min_wal_size = "1GB",
max_wal_size = "4GB",
max_worker_processes = 4,
max_parallel_workers_per_gather = 2,
max_parallel_workers = 4,
max_parallel_maintenance_workers = 2;
And I get this result:
pgbench (14.11 (Ubuntu 14.11-0ubuntu0.22.04.1))
transaction type: sql_query.sql
scaling factor: 1
query mode: prepared
number of clients: 50
number of threads: 4
duration: 400 s
number of transactions actually processed: 2838
latency average = 7114.727 ms
initial connection time = 409.796 ms
tps = 7.027676 (without initial connection time)
statement latencies in milliseconds:
7088.570 SELECT
Even changing any parameter does not helped.