![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've been using pg_autovacuum for a while, and for the most part it's been great. There's one case in my system where it won't run on a particular type of table, even though the table apparently needs it. I have a table called "properties" that has key->value pairs. Usually there are only a handful of rows, some of which are updated relatively frequently compared to the number of rows (hundreds or thousands of times per day). The problem is that some of the rows have long strings for their value (on the order of a few hundred kilobytes), so if I understand correctly, the bulk of the data gets offloaded to a toast table. What I believe is happening is that the main table doesn't meet the minimum activity level for pg_autovacuum based on size / update frequency, but the toast table would, though it isn't specifically checked by pg_autovacuum. The result is that the toast table grows really big before triggering autovacuum (or until I manually vacuum the "properties" table). Not the end of the world, obviously, but might be a "gotcha" for some people with similar situations. |
#3
| |||
| |||
|
|
mark reid wrote: What I believe is happening is that the main table doesn't meet the minimum activity level for pg_autovacuum based on size / update frequency, but the toast table would, though it isn't specifically checked by pg_autovacuum. I don't think the problem has to do with toast, or pg_autovacuum missing the fact that the toast table has been updated. Rather I think the problem is that autovacuum believes that all updates are created equal. |
#4
| |||
| |||
|
|
I think Mark is probably on to something. The activity in the toast table will show as deletes *in the toast table* ... and that activity fails to show at all in the pg_stat_activity view, because it shows only plain relations! So unless autovacuum is ignoring the stats views and going directly to the underlying stats functions, it cannot see at all that there is excessive activity in the toast table. |
|
It strikes me that this is a definitional bug in the stats views. Either we should change the filter to be "regular and toast tables", or we should add columns to show activity in a table's toast table, or we should just add the activity in the toast table to the parent table's activity columns. |
|
The first of these would be easiest but it seems quite likely to break applications (eg, if unmodified, autovacuum would probably try to issue vacuums against toast tables). And the last seems to be confusing. So I think I favor adding columns. |
#5
| |||
| |||
|
|
Tom Lane wrote: The first of these would be easiest but it seems quite likely to break applications (eg, if unmodified, autovacuum would probably try to issue vacuums against toast tables). And the last seems to be confusing. So I think I favor adding columns. |
#6
| |||
| |||
|
|
I think the issue is that a single update to the main table causes a whole bunch of updates to the toast table. So in my case (with the vacuum output attached previously), a thousand updates to the main table entails tens of thousands of updates to the toast table. |
#7
| |||
| |||
|
|
Shouldn't the update to the toast table just be considered an update to table t1? The fact that there is an underlying toast table is an implementation detail that I don't think should show up in the stats system. |
#8
| |||
| |||
|
|
Tom Lane wrote: The first of these would be easiest but it seems quite likely to break applications (eg, if unmodified, autovacuum would probably try to issue vacuums against toast tables). And the last seems to be confusing. So I think I favor adding columns. Hmm. With integrated autovacuum, we could set something up to issue vacuums separately to TOAST tables and the main table. It'd probably be a tad easier if the toast stats are separate from the main table; and an autovac of the main table not necessarily would invoke vacuuming the toast table. I'm not proposing it for 8.1 though ... |
#9
| |||
| |||
|
|
"Matthew T. O'Connor" <matthew (AT) zeut (DOT) net> writes: Shouldn't the update to the toast table just be considered an update to table t1? The fact that there is an underlying toast table is an implementation detail that I don't think should show up in the stats system. At the level of the stats system, though, you are interested in "implementation details". The fact that there is such a concept as an index is an implementation detail according to the SQL standard --- but if we hid that we wouldn't be able to show things that people want to know. In particular, I think people would like to be able to use the stats views to see how much toast-related I/O is going on, and not have that smushed together with main-table I/O. |
#10
| |||
| |||
|
|
Tom Lane wrote: In particular, I think people would like to be able to use the stats views to see how much toast-related I/O is going on, and not have that smushed together with main-table I/O. Fair enough, but how are you planning to display the data, |
![]() |
| Thread Tools | |
| Display Modes | |
| |