Search Postgresql Archives

non-zero xmax yet visible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm a little bit confused by the meaning of xmax.

The documentation at
http://www.postgresql.org/docs/current/static/ddl-system-columns.html
says
"xmax

The identity (transaction ID) of the deleting transaction, or zero for
an undeleted row version. It is possible for this column to be nonzero
in a visible row version. That usually indicates that the deleting
transaction hasn't committed yet, or that an attempted deletion was
rolled back."

According to this, it seems a committed change should result in an
xmax value of zero. But a huge number of rows in our database have
non-zero xmax values and are still visible.

I did the following experiment with 2 sessions.

Session 1

    => create table test_data (id int, value int);
    => insert into test_data(id) values(1);
    => commit;
    => update test_data set value = 1 where id = 1;
    => select txid_current();
     txid_current
    --------------
        362938838

Session 2

    => select xmin, xmax, id, value from test_data;
       xmin    |   xmax    | id | value
    -----------+-----------+----+-------
     362938803 | 362938838 |  1 |

    => update test_data set value = 2 where id = 1;

Session 1

    => commit;

Session 2

    => select txid_current();
     txid_current
    --------------
        362938861

    => commit;
    => select xmin, xmax, id, value from test_data;
       xmin    |   xmax    | id | value
    -----------+-----------+----+-------
     362938861 | 362938861 |  1 |     2


So in this case, xmax is equal to xmin. I've also seen cases where
xmax is larger than xmin and the row is visible.

Is this an expected behavior? How shall we interpret xmax in these cases?


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux