Postgres without a DBA · Part 3 of 3
Can ChatGPT tune PostgreSQL? What an assistant cannot see
A chat assistant tunes the prompt, not the server. Rules measure, the model explains.
Partly. ChatGPT, Claude, Copilot, and Gemini can explain PostgreSQL settings and propose values from the facts in your prompt. They cannot read your server. A setting that depends on how your server behaves, such as shared_buffers or max_wal_size, needs counters that live in PostgreSQL's statistics views. An assistant sees those counters only if you hand them over, and a single paste does not show a rate.
AI-assisted PostgreSQL tuning means asking a language model to propose configuration values. The model works only from what the prompt carries: hardware, workload type, and whatever settings and counters you paste. It does not measure your server. Use it to explain measured findings and to draft statements, not to produce the numbers.
In short
- A chat assistant tunes the prompt, not the server. Of the eight settings Guardioz judges for performance, four need facts that a prompt with RAM, CPU, and workload type never carries: database and table sizes, free disk, and counters such as cache evictions, temporary files, WAL volume, and requested checkpoints.
- Four settings never belong to an assistant:
fsync,full_page_writes,synchronous_commit, andautovacuum. The PostgreSQL 18 documentation ties the first two to unrecoverable data corruption. - Use an assistant to explain measured findings and to draft the statement. Measure before and after every change. To have those counters read every hour on your own server, test Guardioz on your server.
What an assistant sees when you ask it to tune postgresql.conf
An assistant sees the prompt and nothing else. A typical tuning prompt says how much RAM the server has, how many processors, and what kind of workload it runs, for example "a web app". Every value that comes back is built from those three facts plus general knowledge of PostgreSQL.
A PostgreSQL setting can depend on four kinds of facts:
- Hardware: total RAM and the processor count. A typical prompt carries both.
- Configuration: the values PostgreSQL runs with, in the
pg_settingsview. A prompt carries them only if you paste them. - Server sizes: the size of each database, the largest table and index, and the free space on the data disk. A typical prompt carries none of them.
- Workload counters over time: how often the cache evicts blocks, how much data queries write to temporary files, how much WAL the server generates, and how many checkpoints were requested instead of scheduled. These live in the cumulative statistics views. No prompt carries them by default.
The fourth kind does not fit in one paste. The cumulative statistics views count from the last reset. pg_stat_io, pg_stat_database, pg_stat_wal, and pg_stat_checkpointer record its time in a stats_reset column. One reading gives totals over that whole period, an average that hides this week's peaks. A rate needs two readings and the time between them. The Guardioz documentation states the same for its own checks: max_wal_size and a raise of work_mem come from measurements taken between two collections.
Eight PostgreSQL settings and the facts each one needs
Half of the eight performance settings that Guardioz judges need facts that no hardware prompt carries. The table lists, for each setting, the inputs the Guardioz performance tuning check uses, where PostgreSQL 18 keeps each input, and what a prompt with RAM, CPU, and workload type contains.
| ID | Setting | What the check uses | Where PostgreSQL 18 keeps it | In a RAM, CPU, and workload prompt |
|---|---|---|---|---|
| S1 | shared_buffers | Total RAM, the current value, the total size of the monitored databases, and how much data the server pushes out of its cache to make room for new reads | OS memory, pg_settings, pg_database_size(), evictions in pg_stat_io | RAM only. No database size, no evictions. |
| S2 | work_mem | Total RAM, the current shared_buffers, max_connections, and the temporary files that queries write to disk | OS memory, pg_settings, temp_files and temp_bytes in pg_stat_database | RAM only. No temporary files. |
| S3 | maintenance_work_mem | Total RAM, the processor count, the largest table and the largest B-tree index, autovacuum_work_mem, and the number of autovacuum workers | OS facts, pg_relation_size(), pg_settings | RAM and CPU. No table or index sizes. |
| S4 | effective_cache_size | Total RAM and the current value | OS memory, pg_settings | Yes, with the current value pasted |
| S5 | max_worker_processes | The processor count and the current value | OS facts, pg_settings | Yes, with the current value pasted |
| S6 | max_wal_size | How much WAL the server generates, how often a checkpoint was requested instead of started by the schedule, checkpoint_timeout and checkpoint_completion_target, and the free and total space on the data disk | wal_bytes in pg_stat_wal, num_timed and num_requested in pg_stat_checkpointer, pg_settings, the filesystem of the data directory | None of it |
| S7 | checkpoint_completion_target | The current value | pg_settings | Only if you paste the settings |
| S8 | log_hostname | The current value, and whether log lines carry the client host name: log_line_prefix, log_destination, and logging_collector | pg_settings | Only if you paste the settings |
Read the table in three groups. S4 and S5 follow from hardware and the current value, so any prompt with RAM and CPU reaches them. S7 and S8 follow from configuration alone, so a pasted pg_settings covers them. S1, S2, S3, and S6 need sizes or counters from the running server. Guardioz sizes three of them from measured workload: shared_buffers, a raise of work_mem, and max_wal_size. For those three, its documentation says the confidence percentage starts low and rises as the agent collects more history.
pg_settings. Four settings also need facts that only the running server holds. A prompt with RAM, CPU, and workload type fills the first column and nothing else.Four settings an assistant should never change on its own
Four settings trade durability or cleanup for speed, and a person decides each one. Keep them out of any change list an assistant proposes. Part 1 of this series puts the first one at the top of its ten checks for this reason.
- N1
fsync. The PostgreSQL 18 documentation says that turning it off “can result in unrecoverable data corruption in the event of a power failure or system crash.” It adds: “High quality hardware alone is not a sufficient justification for turning off fsync.” - N2
full_page_writes. Turning it off “might lead to either unrecoverable data corruption, or silent data corruption, after a system failure,” per the same page. - N3
synchronous_commit. Off does not corrupt the database, but “some recent allegedly-committed transactions” can be lost in a crash. Whether a payment or an order may vanish after the client saw success is a business decision. - N4
autovacuum. The documentation calls it “an optional but highly recommended feature” and says it needstrack_countsto work. Guardioz reports both settings as Critical when either one is off.
Guardioz treats fsync the same way: its Reliability settings check raises a Critical finding when fsync is not on.
Six rules for using an AI assistant on PostgreSQL
An assistant is useful on PostgreSQL when it works from measurements and a person keeps the decisions. These six rules make that the default.
- R1Give it measurements, not only hardware. Paste the counters each setting depends on, from the table above, with two readings and the time between them. An assistant connected through an MCP server can read statistics views directly. The Postgres MCP Pro README describes a restricted mode that “Limits operations to read-only transactions” and calls it suitable for production environments.
- R2Ask for the evidence behind each value. A value without the counter that justifies it is a rule of thumb. Ask which number from your server moved the recommendation, and what number would change it.
- R3Ask what each change needs to take effect.
shared_buffersandmax_worker_processes“can only be set at server start,” per the PostgreSQL 18 documentation. After a change, thepending_restartcolumn ofpg_settingsshows which values wait for a restart. - R4Never paste statement text with customer data.
pg_stat_activityshows the statement each session runs. The Guardioz documentation notes that a value written in the text, such asWHERE email = 'anna@example.com', travels with it. The same holds for server logs. - R5Apply one change at a time, then measure the same counter. Two changes at once leave no way to tell which one moved the number.
- R6Keep the four settings above out of scope.
fsync,full_page_writes,synchronous_commit, andautovacuumare decisions about risk, and a person makes them.
How to check an assistant's advice on your own server
Treat every proposed value as a claim to test against the same counters before and after the change. Six steps cover it.
- Write down the claim. Name the setting, the new value, and the counter it should move. A higher
work_memshould lowertemp_filesandtemp_bytes. A largershared_buffersshould lower evictions by client backends. A largermax_wal_sizeshould lowernum_requestedrelative tonum_timed. - Take a baseline. Run the query below twice, at the start and the end of a fixed window of normal traffic, for example the same 24 hours on a working day. Keep the timestamps.
- Prepare the rollback before the change. Record the current value from
pg_settings. The statement that undoes anALTER SYSTEM SETisALTER SYSTEM RESETwith the setting name, or a secondALTER SYSTEM SETto the old value. - Apply the one change. Run
ALTER SYSTEM SET, thenSELECT pg_reload_conf();, or restart when the setting needs it. Checkpending_restart. - Measure the same window again. Take two readings over a window of the same length and the same kind of traffic. Compare the change per hour, not the totals.
- Keep it or roll it back. Keep the change only when the counter moved the way the claim said. Write down the result next to the claim.
The baseline query reads only statistics views. A role with pg_monitor can run it on PostgreSQL 18.
SELECT now() AS taken_at,
(SELECT sum(temp_files) FROM pg_stat_database) AS temp_files,
(SELECT sum(temp_bytes) FROM pg_stat_database) AS temp_bytes,
(SELECT sum(evictions) FROM pg_stat_io
WHERE backend_type = 'client backend'
AND object = 'relation'
AND context = 'normal') AS client_evictions,
(SELECT wal_bytes FROM pg_stat_wal) AS wal_bytes,
(SELECT num_timed FROM pg_stat_checkpointer) AS checkpoints_timed,
(SELECT num_requested FROM pg_stat_checkpointer) AS checkpoints_requested;
The current values and their restart state come from one more read-only query:
SELECT name, setting, unit, context, pending_restart
FROM pg_settings
WHERE name IN ('shared_buffers', 'work_mem', 'maintenance_work_mem',
'effective_cache_size', 'max_worker_processes',
'max_wal_size', 'checkpoint_completion_target', 'log_hostname');
A statistics reset between two readings breaks the comparison. Check that stats_reset did not change inside the window.
Rules measure, the model explains
Dr. Kot's position is a split of work. A deterministic check measures and decides what to report. A language model explains the finding and drafts the statement. A check gives the same answer for the same server state, and every answer can be audited against the counter it rests on. A chat answer depends on the prompt, and the prompt holds none of the counters unless someone pastes them.
Research on LLM-based tuning points the same way. λ-Tune, by Victor Giannakouris and Immanuel Trummer, presented at SIGMOD 2025, has a model generate whole configuration scripts from “a large input document, describing the tuning context.” It then picks “the best configuration, out of a small set of candidates” by evaluating them on the system. The model proposes. The measurement decides.
Guardioz is built on the measuring side of that split. Its documentation describes a fixed set of checks, each finding with the measured data it rests on, and a confidence percentage that rises as history accumulates for values sized from the workload. It applies nothing: “You run every command.” Its pricing page answers the chatbot question in one line: “A chatbot answers the question you ask, from what you paste into it.” Guardioz, by contrast, “keeps checking your server, snapshot after snapshot, including the problems you did not think to ask about.”
The two sides work together. Paste a measured finding into an assistant and ask it to explain the setting, the risk, and the rollback. That is the job a language model does well. To compare the tools that sit on the measuring side, from calculators to advisors, read Part 2: calculator, dashboard, or advisor?
Test Guardioz on your server
Guardioz reads the counters in the table above about once an hour on your own server and shows the measurements behind each recommendation, so an assistant has real numbers to explain.
It fits today if you run PostgreSQL 18 yourself, on Linux with systemd or on FreeBSD, and point it at a primary server.
- Book 30 minutes with Dr. Kot to try it on one of your servers.
- Write to the Guardioz team, led by Alicja Kucharczyk, at contact@guardioz.com.
- Start free: one user, up to three servers, no card. Or open the live demo without signing up.
On an older PostgreSQL or a managed service such as Amazon RDS or Azure Database for PostgreSQL? Guardioz does not support it yet. Write to contact@guardioz.com with your version and platform.
Key facts at a glance
From the PostgreSQL 18 documentation, docs.guardioz.com, guardioz.com/pricing, and arXiv, checked on November 4, 2026.
| ID | Fact | Value | Source |
|---|---|---|---|
| K1 | fsync off | “can result in unrecoverable data corruption in the event of a power failure or system crash” | PostgreSQL 18: WAL settings |
| K2 | full_page_writes off | “might lead to either unrecoverable data corruption, or silent data corruption, after a system failure” | PostgreSQL 18: WAL settings |
| K3 | synchronous_commit off | No inconsistency, but recent committed transactions can be lost in a crash. Maximum delay: three times wal_writer_delay. | PostgreSQL 18: WAL settings |
| K4 | Autovacuum | “an optional but highly recommended feature”, needs track_counts | PostgreSQL 18: Routine Vacuuming |
| K5 | Settings that need a restart | shared_buffers and max_worker_processes can only be set at server start | PostgreSQL 18: Resource Consumption |
| K6 | Checkpoint counters | num_timed: scheduled checkpoints due to timeout. num_requested: requested checkpoints. Both in pg_stat_checkpointer. | PostgreSQL 18: pg_stat_checkpointer |
| K7 | Temporary files | temp_files and temp_bytes in pg_stat_database count all temporary files, regardless of log_temp_files | PostgreSQL 18: pg_stat_database |
| K8 | Guardioz performance tuning check | Eight settings. Three are sized from measured workload: shared_buffers, a raise of work_mem, max_wal_size. | Guardioz: What Guardioz checks |
| K9 | Statement text | pg_stat_activity shows statement text, including values written in it | Guardioz: How Guardioz works |
| K10 | λ-Tune | LLM framework that generates whole configuration scripts and picks the best of a small set of candidates. Presented at SIGMOD 2025. | arXiv 2411.03500 |
Frequently asked questions
Can ChatGPT tune PostgreSQL?
Partly. ChatGPT and other assistants can explain PostgreSQL settings and propose values from the facts in your prompt. They cannot read your server. Settings that follow from hardware, such as effective_cache_size and max_worker_processes, are within reach of a prompt that gives RAM and CPU count. Settings sized from measured behavior, such as shared_buffers, a raise of work_mem, and max_wal_size, need counters from PostgreSQL's statistics views that the assistant sees only if you hand them over.
Is it safe to apply postgresql.conf settings from ChatGPT?
Only after you check each one. Reject any change to fsync, full_page_writes, synchronous_commit, or autovacuum unless a person has decided it. Ask for the counter behind every value, apply one change at a time with the rollback statement ready, and measure the same counter before and after. shared_buffers and max_worker_processes take effect only after a restart.
What should I give an AI assistant to tune PostgreSQL?
Give it the hardware, the current values from pg_settings, the database and largest table and index sizes, the free space on the data disk, and two readings of the counters with the time between them: evictions from pg_stat_io, temp_files and temp_bytes from pg_stat_database, wal_bytes from pg_stat_wal, and num_timed and num_requested from pg_stat_checkpointer. Do not paste statement text from pg_stat_activity or logs, because it can carry values from your data.
Can AI replace a DBA for PostgreSQL?
Not on its own. An assistant explains settings and drafts statements, but it does not watch the server, and it decides nothing about durability, backups, or the risk a change carries. A team without a DBA needs a fixed set of checks that runs on the server itself, plus a person who decides. Part 1 of this series lists ten checks in the order they hurt.
Does Guardioz use AI?
The Guardioz documentation describes a fixed set of checks with rules for each one. Each finding shows the measured data it rests on, and a recommendation sized from the server's workload carries a confidence percentage that rises as the agent collects more history. Its pricing page answers the chatbot question directly: a chatbot answers the question you ask from what you paste into it, while Guardioz keeps checking the server and shows the measured data behind each recommendation.
Which PostgreSQL settings can an AI assistant size from RAM and CPU alone?
Of the eight performance settings in the Guardioz checks, two depend only on hardware and their current value: effective_cache_size uses total RAM, and max_worker_processes uses the processor count. Two more, checkpoint_completion_target and log_hostname, depend only on configuration you can paste. The other four, shared_buffers, work_mem, maintenance_work_mem, and max_wal_size, need sizes or counters from the running server.
Why does one paste of pg_stat views not show my workload?
The cumulative statistics views count from the last reset. pg_stat_io, pg_stat_database, pg_stat_wal, and pg_stat_checkpointer record its time in a stats_reset column. One paste gives totals over that whole period, an average that hides this week's peaks. A rate needs two readings and the time between them. The Guardioz documentation says the same of its own checks: max_wal_size and a raise of work_mem come from measurements taken between two collections.
Sources
PostgreSQL 18 documentation, checked on November 4, 2026.
- Write Ahead Log settings: fsync, full_page_writes, synchronous_commit, max_wal_size, checkpoint_completion_target
- Resource Consumption: shared_buffers, work_mem, maintenance_work_mem, max_worker_processes
- Query Planning: effective_cache_size
- Error Reporting and Logging: log_hostname
- Vacuuming: autovacuum
- Routine Vacuuming: the autovacuum daemon
- The Cumulative Statistics System: pg_stat_io, pg_stat_database, pg_stat_wal, pg_stat_checkpointer
- pg_settings
Guardioz, checked on November 4, 2026.
Research and tools, checked on November 4, 2026.