Unix Technical Forum

Indexes and ROWNUM.

This is a discussion on Indexes and ROWNUM. within the Oracle Database forums, part of the Database Server Software category; --> Hi... Simple question.... I wanted to know if I use the ROWNUM in the WHERE clause it disables the ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 08:42 AM
Daniel
 
Posts: n/a
Default Indexes and ROWNUM.

Hi...
Simple question....

I wanted to know if I use the ROWNUM in the WHERE clause it disables the
indexed.
For example: (In the case I have many records with FLD1 = 1)
UPDATE MYTABLE SET FLD2 = 'HELLO WORD' WHERE FLD1 = 1 AND ROWNUM < 2;
If the table has an index, the UPDATE will do a FullScan or it will use
the index if there is any!?!?

Thanks in advance...

Daniel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-23-2008, 08:42 AM
Kristian Myllymäki
 
Posts: n/a
Default Re: Indexes and ROWNUM.


Why don't you do a simple test?

But no, the rownum clause would not change the access path from an index
range scan to a full table scan. If the update uses the index without the
rownum clause it would still use the index but use a COUNT (STOPKEY) to stop
the range scan when it has found the given number of index matches.

The only possible change to a full table scan that I could think of would be
if you used WHERE FLD1 IS NULL.

/Kristian

"Daniel" <danny.icha@usa.net> wrote in message
news:96eef697.0404071144.1722bbac@posting.google.c om...
> Hi...
> Simple question....
>
> I wanted to know if I use the ROWNUM in the WHERE clause it disables the
> indexed.
> For example: (In the case I have many records with FLD1 = 1)
> UPDATE MYTABLE SET FLD2 = 'HELLO WORD' WHERE FLD1 = 1 AND ROWNUM < 2;
> If the table has an index, the UPDATE will do a FullScan or it will use
> the index if there is any!?!?
>
> Thanks in advance...
>
> Daniel



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com