From: Tom Lane <tgl@sss.pgh.pa.us>
To: Brian McCane <bmccane@mccons.net>
Cc: PostgreSQL <pgsql-admin@postgresql.org>
Subject: Re: Strange locking behaviour
Date: Fri, 22 Feb 2002 19:51:26 -0500
Message-ID: <21965.1014425486@sss.pgh.pa.us> (raw)
In-Reply-To: <20020222125330.B18565-100000@fw.mccons.net>
References: <20020222125330.B18565-100000@fw.mccons.net>
Brian McCane <bmccane@mccons.net> writes:
> BEGIN WORK ;
> SELECT stockid FROM stocks WHERE ticker = 'M$FT' FOR UPDATE ;
> UPDATE stocks SET nextupdate = NOW + INTERVAL '1 DAY' ;
> ....Insert 7 years of stock data....
> UPDATE stocks SET nextupdate = NOW() ;
> COMMIT WORK ;
What exactly does the "Insert" step do? Why are you bothering to UPDATE
stocks.nextupdate twice in this transaction? It's not like any other
transaction will be able to see the now + 1 day setting. Do you really
mean to update *all* rows of stocks here?
> The program that gets the 5 minute updates does:
> SELECT stockid FROM stocks WHERE nextupdate <= NOW() ;
> -- and for each stockid it finds above
> BEGIN WORK ;
> ....Insert new data...
> COMMIT WORK ;
Again, what exactly does the "Insert" step do? Does it change
stocks.nextupdate? (One would hope so, else there's a tight loop here.)
If it does, won't it block at that point waiting for the other
transaction's updates to be committed?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, bmccane@mccons.net
Subject: Re: Strange locking behaviour
In-Reply-To: <21965.1014425486@sss.pgh.pa.us>
References: <20020222125330.B18565-100000@fw.mccons.net> <21965.1014425486@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox