Re: n_mod_since_analyze isn't reset at table truncation

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: n_mod_since_analyze isn't reset at table truncation
Date: 2021-03-04 02:24:25
Message-ID: 20210304022425.mcf4hkbefqvyn2s4@nol
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 04, 2021 at 10:35:19AM +0900, Masahiko Sawada wrote:
>
> While reviewing "autoanalyze on partitioned table" patch, I realized
> that pg_stat_xxx_tables.n_mod_since_analyze is not reset at TRUNCATE.
> On the other hand, n_ins_since_vacuum is reset. I think it should be
> reset because otherwise we end up unnecessarily triggering autoanalyze
> even when the actual number of newly inserted tuples is less than the
> autoanalyze thresholds.

Agreed.

> I've attached a small patch to fix this. Please review it.

The patch looks sensible to me, but the stats.sql (around l. 158) test should
be modified to also check for effect on that field.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-03-04 02:25:22 Re: Let people set host(no)ssl settings from initdb
Previous Message tsunakawa.takay@fujitsu.com 2021-03-04 02:24:24 RE: [POC] Fast COPY FROM command for the table with foreign partitions