modification time & transaction synchronisation problem - Mailing list pgsql-general

From Ostrovsky Eugene
Subject modification time & transaction synchronisation problem
Date
Msg-id 55401271336790@web16.yandex.ru
Whole thread Raw
Responses Re: modification time & transaction synchronisation problem
List pgsql-general
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0cm;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:"Times New Roman";}
@page Section1
    {size:595.3pt 841.9pt;
    margin:2.0cm 42.5pt 2.0cm 3.0cm;
    mso-header-margin:35.4pt;
    mso-footer-margin:35.4pt;
    mso-paper-source:0;}
div.Section1
    {page:Section1;}
-->


Hi.
I need to export data from the database to external file. The difficulty is
that only data modified or added since previous export should be written to the
file.
I consider adding "modification_time" timestamp field to all the
tables that should be exported. Then I can set this field to now() within ON
UPDATE OR INSERT trigger.
During export I can select modified data with 'WHERE modification_time >
last_export_time' clause.

It seems to be the solution but...
What if the concurrent (and not yet committed) transaction modified some data
before export transaction begins? These modifications would not be visible to
export transaction and modified data would not be included to export file. Also
it won't be included to the next export because it's modification time is less
than current export start time (the new value of last_export_time).

Thus some data could be lost from export files sequence. And that is not good
at all.

I will appreciate any suggestions on how to solve this problem. I.e. how can I
(within the export transaction) select all the data that was updated since the
last export?

Thanks.
Eugene.

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Complete row is fetched ?
Next
From: "Kincel, Martin"
Date:
Subject: Re: optimalisation with EXCEPT clause