Re: Statistics updates is delayed when using `commit and chain` - Mailing list pgsql-bugs

From Japin Li
Subject Re: Statistics updates is delayed when using `commit and chain`
Date
Msg-id MEYP282MB1669494707E6A49C2AC763FEB6159@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: Statistics updates is delayed when using `commit and chain`  (Lætitia Avrot <laetitia.avrot@gmail.com>)
List pgsql-bugs
On Mon, 12 Jul 2021 at 20:56, Lætitia Avrot <laetitia.avrot@gmail.com> wrote:

> Hello Japin,
>
> Thank you for the patch. I read it and I find myself with one question: why do we update statistics even though there
wasa rollback? I know that that was the behaviour before, but is it still worth it? 
>

I test the following case, and found it also update the statistics even if we
rollback. So I update the statistics here. On the other hands, the insert tuple
rollbacked still in data block, so IMO we should update the statistics. I'm not
sure it is right.

postgres=# create table test (id serial, value text);
CREATE TABLE
postgres=# SELECT n_tup_ins FROM pg_stat_all_tables WHERE relname = 'test';
 n_tup_ins
-----------
         0
(1 row)

postgres=# BEGIN;
BEGIN
postgres=*# INSERT INTO test (value) VALUES ('bla');
INSERT 0 1
postgres=*# SELECT n_tup_ins FROM pg_stat_all_tables WHERE relname = 'test';
 n_tup_ins
-----------
         0
(1 row)

postgres=*# ABORT ;
ROLLBACK
postgres=# SELECT n_tup_ins FROM pg_stat_all_tables WHERE relname = 'test';
 n_tup_ins
-----------
         1
(1 row)

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



pgsql-bugs by date:

Previous
From: Lætitia Avrot
Date:
Subject: Re: Statistics updates is delayed when using `commit and chain`
Next
From: Tom Lane
Date:
Subject: Re: BUG #17101: Inconsistent behaviour when querying with anonymous composite types