Stats not updated after rollback -- autovacuum confused.

Started by Dawid Kuroczkoover 18 years ago6 messages
#1Dawid Kuroczko
qnex42@gmail.com

Hello, I have a system where there are mostly COPYs,
which insert data into a table. Ocasionally a COPY will fail (and thus,
dead rows appear), but as far as I can tell ROLLBACK is not reflected
anywhere in the pg_stats_user_tables. And since there are no rows
n_tup_upd or n_tup_del, therefore autovacuum will not fire for that table.

I see two possible solutions:
1) let rollback increment both n_tup_ins and n_tup_del (or maybe
n_tup_upd, at least)? This would be a good safeguard, I guess.

2) ANALYZE is able to see wether table is accumulating dead rows.
It might be a good idea to make ANALYZE able hint autovacuum that
some tables need VACUUM (that they exceed limits set for autovacuum).

The 2nd point could be a TODO item, perhaps? Something like:
When ANALYZE runs, make it note removable dead rows and non-removable
dead rows. If removable dead rows exceed some threshold, hint autovacuum
at that table.

Regards,
Dawid

#2Bruce Momjian
bruce@momjian.us
In reply to: Dawid Kuroczko (#1)
Re: Stats not updated after rollback -- autovacuum confused.

This has been saved for the 8.4 release:

http://momjian.postgresql.org/cgi-bin/pgpatches_hold

---------------------------------------------------------------------------

Dawid Kuroczko wrote:

Hello, I have a system where there are mostly COPYs,
which insert data into a table. Ocasionally a COPY will fail (and thus,
dead rows appear), but as far as I can tell ROLLBACK is not reflected
anywhere in the pg_stats_user_tables. And since there are no rows
n_tup_upd or n_tup_del, therefore autovacuum will not fire for that table.

I see two possible solutions:
1) let rollback increment both n_tup_ins and n_tup_del (or maybe
n_tup_upd, at least)? This would be a good safeguard, I guess.

2) ANALYZE is able to see wether table is accumulating dead rows.
It might be a good idea to make ANALYZE able hint autovacuum that
some tables need VACUUM (that they exceed limits set for autovacuum).

The 2nd point could be a TODO item, perhaps? Something like:
When ANALYZE runs, make it note removable dead rows and non-removable
dead rows. If removable dead rows exceed some threshold, hint autovacuum
at that table.

Regards,
Dawid

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Alvaro Herrera
alvherre@commandprompt.com
In reply to: Bruce Momjian (#2)
Re: Stats not updated after rollback -- autovacuum confused.

Bruce Momjian escribi�:

This has been saved for the 8.4 release:

http://momjian.postgresql.org/cgi-bin/pgpatches_hold

FWIW this has been fixed in 8.3, you can drop the item from the 8.4
queue. Thanks.

---------------------------------------------------------------------------

Dawid Kuroczko wrote:

Hello, I have a system where there are mostly COPYs,
which insert data into a table. Ocasionally a COPY will fail (and thus,
dead rows appear), but as far as I can tell ROLLBACK is not reflected
anywhere in the pg_stats_user_tables. And since there are no rows
n_tup_upd or n_tup_del, therefore autovacuum will not fire for that table.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#4Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#3)
Re: Stats not updated after rollback -- autovacuum confused.

Removed.

---------------------------------------------------------------------------

Alvaro Herrera wrote:

Bruce Momjian escribi?:

This has been saved for the 8.4 release:

http://momjian.postgresql.org/cgi-bin/pgpatches_hold

FWIW this has been fixed in 8.3, you can drop the item from the 8.4
queue. Thanks.

---------------------------------------------------------------------------

Dawid Kuroczko wrote:

Hello, I have a system where there are mostly COPYs,
which insert data into a table. Ocasionally a COPY will fail (and thus,
dead rows appear), but as far as I can tell ROLLBACK is not reflected
anywhere in the pg_stats_user_tables. And since there are no rows
n_tup_upd or n_tup_del, therefore autovacuum will not fire for that table.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#3)
Re: Stats not updated after rollback -- autovacuum confused.

Alvaro Herrera <alvherre@commandprompt.com> writes:

FWIW this has been fixed in 8.3, you can drop the item from the 8.4
queue. Thanks.

There are a couple of other things on that page that seem already
applied, for instance hashing for numeric and an early form of the
seq scan ringbuffer patch.

While we're griping,
http://momjian.us/pgrelease/
is a bit behind the times...

regards, tom lane

#6Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#5)
Re: Stats not updated after rollback -- autovacuum confused.

Tom Lane wrote:

Alvaro Herrera <alvherre@commandprompt.com> writes:

FWIW this has been fixed in 8.3, you can drop the item from the 8.4
queue. Thanks.

There are a couple of other things on that page that seem already
applied, for instance hashing for numeric and an early form of the
seq scan ringbuffer patch.

Removed.

While we're griping,
http://momjian.us/pgrelease/
is a bit behind the times...

Updated for 8.3 though some of the items aren't active until we enter
beta.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +