Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: update takes to long

Re: update takes to long

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 16 Feb 2007 09:12:31 -0800
Message-ID: <1171645952.94137@bubbleator.drizzle.com>


andersleffler wrote:
> I have a sql statement that really could use som tuning, but I do not
> know how. It is updated by a self join, and contains appr 20000 rows.
> The statement executes on almost 3 minutes. I have rewritten it to an
> anonymous block, but I only reduce the time by half, which is not
> enough. Any help would be appreciated. Thanks
>
> UPDATE a
> SET (sortorder) = (SELECT COUNT (sortorder)
> FROM a b
> WHERE b.PATH <= a.PATH)
>

SQL> SELECT COUNT(*)
   2 FROM gv$reserved_words
   3 WHERE keyword = 'PATH';

   COUNT(*)


          1

SQL> And "FROM a b" is invalid so this is not your actual code.

I see multiple problems with what you have posted, and think you could do yourself a substantial favor if you reposted and included the following:

  1. Oracle version
  2. DDL for table a
  3. DDL for table b
  4. Number of rows in table a
  5. Number of rows in table b
  6. DDL of all indexes on a.path and b.path
  7. Explain plan for the real statement when it is run

But by way of observation ... you are asking for a Cartesian product so the number of actual rows is huge. What is the business case that supports your WHERE clause?

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Fri Feb 16 2007 - 11:12:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US