Re: pgsql: Allow HOT updates for some expression indexes

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org, Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
Subject: Re: pgsql: Allow HOT updates for some expression indexes
Date: 2018-03-28 04:23:08
Message-ID: CANP8+jLMFTBHkueZi_UwUCPfw0vqjeTuzUwmLnn1k2A16t7-6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 27 March 2018 at 22:26, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
>> The test script appears to imagine that pgstats outputs update
>> instantaneously.
>
> Oh, wait, it's looking at pg_stat_xact, which is the *local*, unsent
> stats information. So your problem is actually the reverse of that:
> if the test runs too slowly, it fails, because at some point the
> unsent stats information will get flushed out to the collector and
> disappear from the pg_stat_xact view.
>
> You could probably make this more reliable by wrapping each test
> stanza in a transaction, ie instead of
>
> create table keyvalue ...;
> ... do something to table ...
> select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
> drop table keyvalue;
>
> do
>
> begin;
> create table keyvalue ...;
> ... do something to table ...
> select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
> rollback;
>
> (no need for a DROP if you're rolling it all back)

Oh wow, thanks. Fixed.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-03-28 04:25:00 Re: pgsql: Fast ALTER TABLE ADD COLUMN with a non-NULL default
Previous Message Simon Riggs 2018-03-28 04:22:07 pgsql: Use pg_stat_get_xact* functions within xacts