Unix Technical Forum

oracle indexes

This is a discussion on oracle indexes within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hello, Say If I have a table with column a, and column b (say they are integers). Sometimes I ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-05-2008, 06:17 AM
doug
 
Posts: n/a
Default oracle indexes



Hello,

Say If I have a table with column a, and column b (say they are
integers).

Sometimes I will do a query with a where clause that just references
column a.

Sometimes I will do a query with a where clause that references both
column a and b.

Is there a need to create an index with a, and an index with a, b? Or
will an index with a,b work for both of the above types of queries?




I know in mysql if I have an index (a, b, c), then it is useful for
queries referencing a or a,b or a, b,c. But, I am not as familiar
with how Oracle indexes work.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-05-2008, 06:17 AM
news.verizon.net
 
Posts: n/a
Default Re: oracle indexes


"doug" <douglass_davis@earthlink.net> wrote in message
news:a95d43e0-f441-4fc8-8943-75c2e4a90e86@8g2000hse.googlegroups.com...
>
>
> Hello,
>
> Say If I have a table with column a, and column b (say they are
> integers).
>
> Sometimes I will do a query with a where clause that just references
> column a.
>
> Sometimes I will do a query with a where clause that references both
> column a and b.
>
> Is there a need to create an index with a, and an index with a, b? Or
> will an index with a,b work for both of the above types of queries?
>
>
>
>
> I know in mysql if I have an index (a, b, c), then it is useful for
> queries referencing a or a,b or a, b,c. But, I am not as familiar
> with how Oracle indexes work.
>
> Thanks.

It depends on the version; there are some subtle differences. (eg index
skip scan) In Oracle 7 and 8 if you created an index on a,b then a search
on a could use the index and a search on a and b could use the index. A
search only on b could not.
Jim


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-05-2008, 06:39 PM
DA Morgan
 
Posts: n/a
Default Re: oracle indexes

doug wrote:
>
> Hello,
>
> Say If I have a table with column a, and column b (say they are
> integers).
>
> Sometimes I will do a query with a where clause that just references
> column a.
>
> Sometimes I will do a query with a where clause that references both
> column a and b.
>
> Is there a need to create an index with a, and an index with a, b? Or
> will an index with a,b work for both of the above types of queries?
>
>
>
>
> I know in mysql if I have an index (a, b, c), then it is useful for
> queries referencing a or a,b or a, b,c. But, I am not as familiar
> with how Oracle indexes work.
>
> Thanks.


Assuming a currently supported version of Oracle it works the same
way. It will even in many cases support a query on b and b,c that
does not include a.

But you have, for some reason, not provided version information so
this response is purely generic.

Oracle changes, often dramatically from version to version with
respect to specific functionality. Always, when asking Oracle
questions include full version information ... 3+ decimal places.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-06-2008, 06:30 AM
joel garry
 
Posts: n/a
Default Re: oracle indexes

On Jun 4, 9:01*pm, doug <douglass_da...@earthlink.net> wrote:
> Hello,
>
> Say If I have a table with column a, and column b (say they are
> integers).
>
> Sometimes I will do a query with a where clause that just references
> column a.
>
> Sometimes I will do a query with a where clause that references both
> column a and b.
>
> Is there a need to create an index with a, and an index with a, b? *Or
> will an index with a,b work for both of the above types of queries?
>
> I know in mysql if I have an index (a, b, c), then it is useful for
> queries referencing a or a,b or a, b,c. *But, I am not as familiar
> with how Oracle indexes work.
>
> Thanks.


You should read about indexing in the concepts manual and the
performance tuning manual. You can also search http://tahiti.oracle.com
for the skip scan Jim mentioned, which answers your question.

Once you become comfortable with the basic concepts, you can delve
deeper in many places, especially http://richardfoote.wordpress.com/
(be sure and check out the index internals presentation).

jg
--
@home.com is bogus.
“I just don't understand why kids would do a stupid thing like
that...” http://www.signonsandiego.com/uniont...s_1n5nude.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-06-2008, 06:30 AM
news.verizon.net
 
Posts: n/a
Default Re: oracle indexes


"joel garry" <joel-garry@home.com> wrote in message
news:e280efa1-9fb4-482f-957b-a81eba7086de@l28g2000prd.googlegroups.com...
On Jun 4, 9:01 pm, doug <douglass_da...@earthlink.net> wrote:
> Hello,
>
> Say If I have a table with column a, and column b (say they are
> integers).
>
> Sometimes I will do a query with a where clause that just references
> column a.
>
> Sometimes I will do a query with a where clause that references both
> column a and b.
>
> Is there a need to create an index with a, and an index with a, b? Or
> will an index with a,b work for both of the above types of queries?
>
> I know in mysql if I have an index (a, b, c), then it is useful for
> queries referencing a or a,b or a, b,c. But, I am not as familiar
> with how Oracle indexes work.
>
> Thanks.


You should read about indexing in the concepts manual and the
performance tuning manual. You can also search http://tahiti.oracle.com
for the skip scan Jim mentioned, which answers your question.

Once you become comfortable with the basic concepts, you can delve
deeper in many places, especially http://richardfoote.wordpress.com/
(be sure and check out the index internals presentation).

jg
--
@home.com is bogus.
“I just don't understand why kids would do a stupid thing like
that...”
http://www.signonsandiego.com/uniont...s_1n5nude.html

I had forgotten to mention Richard Foote's web site. It is excellent. Lots
of fantastic information there.
Jim


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 07:10 AM.


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