mirror of
https://github.com/postgres/postgres.git
synced 2025-07-24 14:22:24 +03:00
Use pg_stat_get_xact* functions within xacts
Resolve build farm failures from c203d6cf81
,
diagnosed by Tom Lane.
The output of pg_stat_get_xact_tuples_hot_updated() and friends
is not guaranteed to show anything after the transaction completes.
Data is flushed slowly to stats collector, so using them can
give timing issues.
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
begin;
|
||||
create table keyvalue(id integer primary key, info jsonb);
|
||||
create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=false);
|
||||
insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
|
||||
@ -8,7 +9,8 @@ select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
0
|
||||
(1 row)
|
||||
|
||||
drop table keyvalue;
|
||||
rollback;
|
||||
begin;
|
||||
create table keyvalue(id integer primary key, info jsonb);
|
||||
create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=true);
|
||||
insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
|
||||
@ -33,7 +35,8 @@ select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
2
|
||||
(1 row)
|
||||
|
||||
drop table keyvalue;
|
||||
rollback;
|
||||
begin;
|
||||
create table keyvalue(id integer primary key, info jsonb);
|
||||
create index nameindex on keyvalue((info->>'name'));
|
||||
insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
|
||||
@ -58,4 +61,4 @@ select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
2
|
||||
(1 row)
|
||||
|
||||
drop table keyvalue;
|
||||
rollback;
|
||||
|
@ -1,10 +1,12 @@
|
||||
begin;
|
||||
create table keyvalue(id integer primary key, info jsonb);
|
||||
create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=false);
|
||||
insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
|
||||
update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
|
||||
select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
drop table keyvalue;
|
||||
rollback;
|
||||
|
||||
begin;
|
||||
create table keyvalue(id integer primary key, info jsonb);
|
||||
create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=true);
|
||||
insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
|
||||
@ -14,8 +16,9 @@ update keyvalue set info='{"name": "smith", "data": "some other data"}' where id
|
||||
select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
update keyvalue set info='{"name": "smith", "data": "some more data"}' where id=1;
|
||||
select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
drop table keyvalue;
|
||||
rollback;
|
||||
|
||||
begin;
|
||||
create table keyvalue(id integer primary key, info jsonb);
|
||||
create index nameindex on keyvalue((info->>'name'));
|
||||
insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
|
||||
@ -25,6 +28,6 @@ update keyvalue set info='{"name": "smith", "data": "some other data"}' where id
|
||||
select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
update keyvalue set info='{"name": "smith", "data": "some more data"}' where id=1;
|
||||
select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
|
||||
drop table keyvalue;
|
||||
rollback;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user