Обсуждение: Re: pg_stat_statements: improve loading and saving routines for the dump file

Поиск
Список
Период
Сортировка

Re: pg_stat_statements: improve loading and saving routines for the dump file

От
Ivan Kush
Дата:
Hello, Mikhail.

1) I'd add to comment a reason, why mutex should be last.

// Mutex should be last field, as this field isn't copied to dump file

+    /* protects the counters only. Should be the very last field, as this field isn't copied to dump file
+    slock_t        mutex;
  } pgssEntry;

2) You didn't take into account the upgrade. Saved in Postgres with this 
byte and try to load in version without this byte.

On 1/20/25 16:49, m.litsarev@postgrespro.ru wrote:
> Hi!
>
> Currently in pg_stat_statements save/load routines the whole pgssEntry 
> entity data are written/read with its last field
> slock_t        mutex;
> which is actually not used then.
> This small patch fixes this issue. Hope, it will be useful.
>
> Respectfully,
>
> Mikhail Litsarev,
> Postgres Professional: https://postgrespro.com

-- 
Best wishes,
Ivan Kush
Tantor Labs LLC




Re: pg_stat_statements: improve loading and saving routines for the dump file

От
Ivan Kush
Дата:
What does this patch give on aglobal scale? Does it save much memory or 
increase performance? How many times?

On 1/21/25 13:51, m.litsarev@postgrespro.ru wrote:
>> // Mutex should be last field, as this field isn't copied to dump file
> Updated.
>
>> 2) You didn't take into account the upgrade. Saved in Postgres with 
>> this byte and try to load in version without this byte.
> The PGSS_DUMP_FILE format is defined by PGSS_FILE_HEADER magic number 
> (the first four bytes in the dump file). Once they does not coinside 
> (when the file is being read) the statistics are not loaded from the 
> dump file and set to zero and the irrelevant dump file is skipped. 
> This is the actual behaviour implemented in the code.
>
> Respectfully,
>
> Mikhail Litsarev,
> Postgres Professional: https://postgrespro.com

-- 
Best wishes,
Ivan Kush
Tantor Labs LLC




Re: pg_stat_statements: improve loading and saving routines for the dump file

От
Sami Imseih
Дата:
This will only reduce the size of the
$PGDATA/pg_stat/pg_stat_statements.txt file. Even with
100k entries, the most I have seen pg_stat_statements.max
set to, that will be less than 1 MB of disk saving. The default
config of 5k entries will be much less.

Regards,

Sami



Re: pg_stat_statements: improve loading and saving routines for the dump file

От
m.litsarev@postgrespro.ru
Дата:
> What does this patch give on aglobal scale? Does it save much memory or 
> increase performance? How many times?

This patch makes the code semantically more correct and we don't lose 
anything. It is obviously not about performance or memory optimisation.

> This will only reduce the size of the
> $PGDATA/pg_stat/pg_stat_statements.txt file. Even with
> 100k entries, the most I have seen pg_stat_statements.max
> set to, that will be less than 1 MB of disk saving. The default
> config of 5k entries will be much less.

Perfectly agree. I would just add that statistics are dropped into the 
pg_stat_statements.txt file at server stop which is not a very frequent 
event.

Respectfully,

Mikhail Litsarev,
Postgres Professional: https://postgrespro.com