Re: keeping track of function execution

From: justin <justin(at)emproshunts(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: keeping track of function execution
Date: 2009-05-03 16:43:58
Message-ID: 49FDC9CE.8090100@emproshunts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Wojtek wrote:
<blockquote cite="mid:49FDBA8D(dot)2030301(at)twine(dot)pl" type="cite">Hi, <br>
<br>
I have a question on transactions/isolation levels/etc... <br>
In my PL/pgSQL function main loop goes through inventory list of active
devices, for each one executing processing applicable for given device,
like: <br>
FOR i in --i is %rowtype <br>
select device_id as device_id, <br>
type as type <br>
from devices_list <br>
where active = 1 <br>
LOOP <br>
&nbsp;&nbsp; (...) <br>
-- here is CASE statement, checking value of 'type' parameter <br>
&nbsp; (....) <br>
END LOOP; --simple enough, right? <br>
<br>
This processing is pretty heavy and takes lot of time... so, I'd like
to be able to monitor as processing progresses and I need to be able to
say: <br>
-which devices've been processed already <br>
-which ones've not been processed yet <br>
<br>
My first idea was to create table, updated by my function each time
next device is processed, like: <br>
device_id;status <br>
1;0--done <br>
2;0--done <br>
3;1--processing is running <br>
4;2--to be processed <br>
<br>
But... Postgress treats function as single transaction, of course.
Hence, I'm not able to see any changes in my progress monitoring table
until my main function is finished and all the statuses are set to 0.
Which is not really the intent (again, the intent is to be able to
monitor which devices are yet to be processed while function is still
running!) <br>
<br>
My ideas so far (none is perfect, unfortunately) <br>
- move my loop to php/other external piece of code... so it will log-in
progress in my function using separate transactions (well, I don't want
to use external code, would prefer to stay in PL/pgSQL) <br>
- log to text file (slow and not easy to report later on) <br>
<br>
Can I ask for any other suggestions/comments? Is there a way I can have
this functionality, please? <br>
<br>
Regards, <br>
foo <br>
<br>
</blockquote>
<font face="Arial">What about using Triggers when a device is being
processed throw a flag in anther table or in the same table.&nbsp; <br>
<br>
I'm guessing some other kind of process set the status 0, 1 or 2 before
this slow process gets going.&nbsp; if that is the case just add a trigger
on update to set the status.&nbsp; Then a simple query&nbsp; will get you what
you want.<br>
<br>
If&nbsp; I'm understanding what your after.<br>
</font>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.5 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-05-03 18:22:10 Re: keeping track of function execution
Previous Message Ron Mayer 2009-05-03 16:19:43 Re: Difference between array column type and separate table