A DB instance uses only one DB parameter group at a time. When you change the group of a DB instance, RDS marks it Pending reboot: the new group, including its dynamic parameters, takes effect only after you reboot the DB instance. After that, changes to dynamic parameters in the same group apply without a reboot.
Choose Databases, select rdspg-lab-db, then choose Modify. Scroll down to Additional configuration > Database options:
rdspg-lab-pg18
Choose Continue. On the summary page:
default.postgres18 → rdspg-lab-pg18.
Choose rdspg-lab-db and open the Configuration tab:
rdspg-lab-pg18 with the status Pending reboot.
Choose Actions > Reboot:
rdspg-lab-db.
When the Status is Available again, the parameter group status is In sync.
From the App server (ssh rdspg-app), run:
psql -d pglab -c "SHOW log_connections;" \
-c "SHOW log_min_duration_statement;" \
-c "SELECT pg_sleep(5);"
log_connections is receipt,authentication,authorization.log_min_duration_statement is 4s (4000 ms).pg_sleep(5) runs for 5 seconds, longer than the 4-second limit, so PostgreSQL writes it to the log.
The PostgreSQL log now has lines such as connection authorized: user=postgres database=pglab and duration: 5005.123 ms statement: SELECT pg_sleep(5);. Open them in the console (Logs & events > Logs) or, if you export the PostgreSQL log, in CloudWatch Logs (/aws/rds/instance/rdspg-lab-db/postgresql).
log_connections and a low log_min_duration_statement can produce a lot of log data on a busy database. In production, choose a threshold that only catches the queries that you want to fix.