Re: Which query is best?

  • From: Syed Jaffar Hussain <sjaffarhussain@xxxxxxxxx>
  • To: Niall Litchfield <niall.litchfield@xxxxxxxxx>
  • Date: Tue, 15 Dec 2009 16:34:12 +0300

Thank you all for your valuable inputs. I had a little discussion with the
developers and tried to understand their logic and questioned them what
actually leads into this situation. They have explained me that, they have a
SELECT .. FOR UPDATE and some other series of actions and then followed by
an UPDATE command. It could be possible that a user might not have completed
the previous transaction, (due to any technical or nontechnical reasons)
might have tried with another session for the same action. Hence, they said,
they are going to put the time out value at the end of SELECT .. FOR UPDATE
command, probably 60 seconds time out for the lock.



On Tue, Dec 15, 2009 at 4:22 PM, Niall Litchfield <
niall.litchfield@xxxxxxxxx> wrote:

> comments in line
> On Tue, Dec 15, 2009 at 9:50 AM, Stephane Faroult 
> <sfaroult@xxxxxxxxxxxx>wrote:
>> And although I don't agree on everything with Celko, I have always found
>> he hits the nail on the head here
>> Four years old article, and still fresh ...
> It is a nice article, sadly I suspect it will still apply in 10 years from
> now.
>> SF
>> Syed Jaffar Hussain wrote:
>> > My main idea behind looking for an alternative sql was to reduce the
>> > waiting time for the select time to avoid long locking period for the
>> > record.
> snipped to hopefully avoid over quoting.
> Any chance of sharing the update and it's plan?, and maybe how it is called
> - I often see this sort of thing in a loop in pl/sql (or worse in the client
> language)
> <pseudocode>
> for <some loop condition> loop
> select <key values> where <current loop condition values>
> update something where key = <key values from previous select>
> end loop
> </pseudocode>
> nearly always what is meant is
> update something where <loop condition>
> :(
> It looks like your logic might be a little different though. As Stephane
> implies understanding the whole of the transaction and thinking through the
> appropriate business approach is often the best approach in cases like
> these. Incidentally do you have very many more iterations of this logic than
> you have user sessions (assuming it is an interactive query)
> Niall
> --
> Niall Litchfield
> Oracle DBA

Best Regards,

Syed Jaffar Hussain
Oracle Certified Master (10g)
Oracle ACE
OCP 8i,9i & 10g DBA
RAC Certified Expert
Official Oracle RAC SIG Representative for Saudi Arabian region  (
I blog at
LinkedIn :
"Winners don't do different things. They do things differently."

Other related posts: