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.