| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | Andres Freund <andres(at)anarazel(dot)de>, Daniel Gustafsson <daniel(at)yesql(dot)se>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Split index and table statistics into different types of stats |
| Date: | 2026-08-10 07:42:58 |
| Message-ID: | anmBAdAlr8oJTPHZ@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Aug 10, 2026 at 04:40:54AM +0000, Bertrand Drouvot wrote:
> I had a look at 0001 only, and I've a few comments.
Thanks for the review.
> === 1
>
> +pgstat_index_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
> +{
> [...]
> + /* The entry was successfully flushed, add the same to database stats */
> + dbentry = pgstat_prep_database_pending(dboid);
> + dbentry->blocks_fetched += lstats->counts.blocks_fetched;
> + dbentry->blocks_hit += lstats->counts.blocks_hit;
>
> Shouldn't we add tuples_returned and tuples_fetched here too?
Argh. I have missed these two. Nice catch.
> === 2
> But it looks like that pg_stat_get_xact_numscans() descr has not been updated
> in pg_proc.dat although it now returns 0 for indexes.
Indeed. This needs to be updated. Done now in the attached.
A test could be in place here, I guess, but we cannot make it relevant
except in a TAP test where the counter increments would be isolated.
Will look at how possible this could be later. For now, I will do an
extra pass later on this patch. Updated version is attached for now.
> There is no public doc for pg_stat_get_numscans() and pg_stat_get_xact_numscans(),
> so existing callers will get different behavior (that is not publicly documented).
>
> Should we preserve the old behavior while keeping the new functions as explicit
> alternatives? Or is it less of an issue given that those 2 don't have public
> doc?
pg_stat_get_xact_numscans() is only called for
pg_stat_xact_all_tables. pg_stat_get_numscans() is only called for
pg_stat_all_tables. Both apply to relkind IN ('r', 't', 'm', 'p').
So returning 0 is not a big deal IMO. We have never used that for
indexes, and the table behavior is untouched. So I think that the
patch as-is looks fine on this side.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| v15-0001-Split-PgStat_StatTabEntry-into-separate-table-an.patch | text/plain | 47.7 KB |
| v15-0002-Refactor-PgStat_TableStatus-to-new-PgStat_Relati.patch | text/plain | 44.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-08-10 08:03:35 | Re: Support for 8-byte TOAST values, round two |
| Previous Message | Hannu Krosing | 2026-08-10 07:37:43 | Re: Support for 8-byte TOAST values, round two |