modification time & transaction synchronisation problem

From: Ostrovsky Eugene <e79ene(at)yandex(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: modification time & transaction synchronisation problem
Date: 2010-04-15 13:06:30
Message-ID: 55401271336790@web16.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<META content="text/html; charset=utf-8" http-equiv="Content-Type" ></META><META content="Word.Document" name="ProgId" ></META><META content="Microsoft Word 11" name="Generator" ></META><META content="Microsoft Word 11" name="Originator" ></META><LINK href="file:///C:\Users\1\AppData\Local\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" ></LINK><O:SMARTTAGTYPE name="City" namespaceuri="urn:schemas-microsoft-com:office:smarttags" ></O:SMARTTAGTYPE><O:SMARTTAGTYPE name="place" namespaceuri="urn:schemas-microsoft-com:office:smarttags" ></O:SMARTTAGTYPE><STYLE >
&lt;!--
/* 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;}
--&gt;
</STYLE>

<SPAN lang="EN-US" style="" >Hi.<br />
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.<br />
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.<br />
During export I can select modified data with 'WHERE modification_time &gt;
last_export_time' clause.<br />
<br />
It seems to be the solution but...<br />
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).<br />
<br />
Thus some data could be lost from export files sequence. And that is not good
at all.<br />
<br />
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?<br />
<br />
Thanks.<br />
<ST1:CITY w:st="on" ><ST1:PLACE w:st="on" >Eugene</ST1:PLACE></ST1:CITY>.<O:P ></O:P></SPAN><br />

Attachment Content-Type Size
unknown_filename text/html 2.3 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Satish Burnwal (sburnwal) 2010-04-15 13:31:41 Re: Query is stuck
Previous Message dipti shah 2010-04-15 10:46:06 Re: How to get whether user has ALL permissions on table?