Skip to content

check_last_maintenance : filter out small tables#426

Open
yhuelf wants to merge 2 commits into
OPMDG:masterfrom
yhuelf:check_last_maintenance_filter_out_small_tables
Open

check_last_maintenance : filter out small tables#426
yhuelf wants to merge 2 commits into
OPMDG:masterfrom
yhuelf:check_last_maintenance_filter_out_small_tables

Conversation

@yhuelf
Copy link
Copy Markdown
Contributor

@yhuelf yhuelf commented Jun 3, 2026

What is the purpose of the last_vacuum and last_analyze probes?

  • To be alerted when statistics are reset following a crash, a failover, etc.
  • To detect large tables that are no longer being processed frequently enough due to the default autovacuum settings, which are not always well-suited for large tables.

Alerts for small tables therefore constitute unnecessary noise.

yhuelf added 2 commits June 3, 2026 11:09
What is the purpose of the `last_vacuum` and `last_analyze` probes?

* To be alerted when statistics are reset following a crash, a failover,
  etc.
* To detect large tables that are no longer being processed frequently
  enough due to the default autovacuum settings, which are not always
  well-suited for large tables.

Alerts for small tables therefore constitute unnecessary noise.
Copy link
Copy Markdown
Collaborator

@blogh blogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a great addition.

Comment thread README
This service supports a "--analyze_table_min_size" parameter to
exclude small relations. The value must be a positive integer
representing the threshold in kilobytes below which the relation
is excluded. This defaults to 1024 (1MB).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should specify that we are talking about the "main fork" and maybe reflect
this in the parameter name.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect units to work here.

I don't know if that's necessary, we will likely filter small table so the value should be easy to
read whthout it. But it would be consistent with other sizes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main fork only? toast not included?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main fork only? toast not included?

Yes because the toast table is processed separately by autovacuum. The main fork could be only 8kB, 100 tuples, never vacuumed, while the toast table can be 100MB, 50000 tuples, already vacuumed. If you use pg_table_size instead of pg_relation_size, you will get an alert for the main fork, and we don't want that.

Comment thread README
This service supports a "--vacuum_table_min_size" parameter to
exclude small relations. The value must be a positive integer
representing the threshold in kilobytes below which the relation
is excluded. This defaults to 10240 (10MB).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as --analyze_table_min_size

Comment thread README
This service supports a "--analyze_table_min_size" parameter to
exclude small relations. The value must be a positive integer
representing the threshold in kilobytes below which the relation
is excluded. This defaults to 1024 (1MB).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main fork only? toast not included?

Comment thread check_pgactivity
'wal_buffers' => undef,
'checkpoint_segments' => undef,
'effective_cache_size' => undef,
'vacuum_table_min_size' => 10 * 1024,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 MB is already too much I think.

Most small tables that gives false alarms are only a few blocks wide.

We can discuss at length the right limit, but since we had service that was much too sensitive, perhaps shall we raise the bar not so high.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about 2 MB ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 1000 tuples would be a better threshold (autovacuum_vacuum_insert_threshold default value).

A 2MB table should contains at least that number of tuples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants