Re: Help with concurrent insertions. - Mailing list pgsql-novice

From Christopher Browne
Subject Re: Help with concurrent insertions.
Date
Msg-id m3wtu1txvs.fsf@knuth.knuth.cbbrowne.com
Whole thread Raw
In response to Help with concurrent insertions.  ("Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar.Pyatalo@honeywell.com>)
List pgsql-novice
Centuries ago, Nostradamus foresaw when Pradeepkumar.Pyatalo@honeywell.com ("Pradeepkumar, Pyatalo (IE10)") would
write:
> Could anyone help me out with this.

May I suggest doing a slightly different "interlock"?

mobile% echo $$
65425

--> At the start of your update process, determine your process's
    PID.  Let's suppose it's 65425.

--> First query:
     update ebihistory set flag = 65425 where flag = 0

    That claims all records with flag = 0 for the local process.

--> Then, to process them...

    select [whatever] from pointtable p, ebihistory e
    where p.pointid = e.pointnumber and e.flag = 65425;

--> Then, once they're done

    update ebihistory set flag = 1 where flag = 65425

If there is some possibility of processes failing, you might want to
make sure that there's no update process running, and then run the
query:

   update ebihistory set flag = 0 where flag > 1;

That draws back to 0 [unclaimed] any entries that haven't had
processing finished yet.
--
let name="cbbrowne" and tld="gmail.com" in name ^ "@" ^ tld;;
http://cbbrowne.com/info/internet.html
I am not a Church numeral!
I am a free variable!

pgsql-novice by date:

Previous
From: Márcio Vinícius
Date:
Subject: BatchMove with PostgreSQL
Next
From: Klaus
Date:
Subject: How to create Geo Types from numeric?