
daniela
High Performance PostgreSQL for Rails: How to show autovacuum_vacuum_scale_factor per table (p. 171)
On page 171, it shows how to change the autovacuum scale factor for a particular table, eg:
ALTER TABLE trips SET (autovacuum_vacuum_scale_factor = 0.01);
It’s also possible to show from in a psql console what the global value is for the scale factor:
SHOW autovacuum_vacuum_scale_factor;
My question is: How to show the table-specific values? i.e. suppose someone else has gone in and updated this for various tables, and you just want to know what all the current values are before making further changes?
First Post!

andatki
Hey Daniela! Good question. I’m adding a query (thanks ChatGPT) you can run on your DB to find this information. We can query the pg_class
system catalog to get it. To test this, I set the AV scale factor using the command you listed and made sure the expected option name and value appeared in the result.
Because this seems generally useful, I’ve added this query to my pg_scrips
repository on GitHub. There’s also a commented out section showing the result when run on my local Rideshare DB.
Besides querying this information, another tactic could be adding these changes to your local dev DB, since they’re dumped into the db/structure.sql
.
Here’s a snippet below where Autovacuum was disabled for a table, showing the line it adds to db/structure.sql
.
While this AV change wouldn’t likely wouldn’t be necessary locally, documenting a change like this in the db/structure.sql
could be helpful on a team of people interested in this info.
“+WITH (autovacuum_enabled='false');”
Hope that helps!
Popular Pragmatic topics










Other popular topics








Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim