Closed Thread
Results 1 to 7 of 7

Thread: Oracle ROWNUM

  1. #1
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Oracle ROWNUM

    I've recently been struggling with a 30 minute
    response times on an Oracle database.
    3 tables, 1 (rather large) existing view,
    2 left outer joins and 1 inner join.

    I'm not going to bother posting the db schema and
    all the sql because there is quite a lot of it.

    I decided to create a manageable view which took
    care of 3 tables, but didn't help when I inner joined
    it to the large existing view. So I decided to dynamically
    create a small view containing a small subset (5K) of the
    normal 50K record output, but how do I limit the records.
    In SQL server TOP, MySQL LIMIT and Oracle ROWNUM which
    brings me back to my buddy phillw and how he uncovered
    that LIMIT does the full query anyway and delivers a subset.

    Now Oracle assigns a ROWNUM to rows returned so you have to
    Select * FROM (Select your actual query) where ROWNUM < something
    and this didn't help response time.

    I realized that Oracle assigning a ROWNUM could be used, so I created
    the full view including ROWNUM (Select ROWNUM etc...) just like
    selecting an existing field which worked like an auto-increment field.
    Now I joined the 2 views where ROWNUM between X and X and
    delivered 5K subsets of the output which each took about 1 minute.
    30 minutes became 10 minutes.
    via a non-standard use of ROWNUM in Oracle.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Oracle ROWNUM

    Now THAT is cool
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Re: Oracle ROWNUM

    Yes very cool, I tried multiple views, queries w/ sub-queries,
    grouping with rank, normal ROWNUM usage, etc...
    nothing worked until I misused ROWNUM to create
    a unique id column while creating a dynamic view.

    Just add ROWNUM to the select portion of the
    Create or replace view as... query.
    Oracle only!!

    Sometimes it's the little things that make a big
    difference to me.

  5. #4
    Jordan Guest

    Re: Oracle ROWNUM

    Impressive!

  6. #5
    phillw's Avatar
    phillw is offline Learning Programmer
    Join Date
    Aug 2009
    Location
    Northwest England (UK)
    Posts
    82
    Blog Entries
    1
    Rep Power
    0

    Re: Oracle ROWNUM

    That's one cool bit of lateral thinking !!!

    ... btw .. it wasn't you searching for the "green cookie monster" on the ft test area, was it ? - lol
    No idea who it was - but it did make me chuckle :-)

    Phill.

  7. #6
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Re: Oracle ROWNUM


  8. #7
    phillw's Avatar
    phillw is offline Learning Programmer
    Join Date
    Aug 2009
    Location
    Northwest England (UK)
    Posts
    82
    Blog Entries
    1
    Rep Power
    0

    Re: Oracle ROWNUM

    The site counter I have installed showed someone searching for that phrase

    The google bot also found the test site & dutifully indexed it all up - a hit came from someone searching for a part on google - lol

    I guess I'd better hurry and get it all finished now !!

    Phill.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Oracle and MySQL
    By jivkoss in forum Database & Database Programming
    Replies: 3
    Last Post: 10-12-2010, 05:28 AM
  2. Oracle 10g (Help)
    By ahmed in forum Database & Database Programming
    Replies: 5
    Last Post: 04-26-2010, 06:16 AM
  3. Oracle
    By databox in forum Introductions
    Replies: 6
    Last Post: 01-17-2010, 05:33 AM
  4. Limit in Oracle
    By Apaul in forum Database & Database Programming
    Replies: 2
    Last Post: 05-18-2009, 02:37 PM
  5. Oracle?
    By Lop in forum C# Programming
    Replies: 7
    Last Post: 09-29-2006, 03:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts