View previous topic :: View next topic |
Author |
Message |
kbn Beginner
Joined: 14 Nov 2005 Posts: 13 Topics: 10
|
Posted: Thu Jan 17, 2008 2:30 am Post subject: Effective query |
|
|
Hi,
I have a table T1 with an index I1 with columns C1, C2, C3 in sequence.
Which of the below query is effective?
select * from T1
where C1 = 'a'
and C2 = 'b'
and C3 >= 'c'
OR
select * from T1
where C2 = 'a'
and C1 = 'b'
and C3 >= 'c'
thanks,
kbn |
|
Back to top |
|
|
vkphani Intermediate
Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Thu Jan 17, 2008 4:52 am Post subject: Re: Effective query |
|
|
kbn wrote: | Hi,
I have a table T1 with an index I1 with columns C1, C2, C3 in sequence.
Which of the below query is effective?
select * from T1
where C1 = 'a'
and C2 = 'b'
and C3 >= 'c'
OR
select * from T1
where C2 = 'a'
and C1 = 'b'
and C3 >= 'c'
thanks,
kbn |
kbn,
If you consider the execution time, both the queries takes same time to execute. |
|
Back to top |
|
|
acevedo Beginner
Joined: 03 Dec 2002 Posts: 127 Topics: 0 Location: Europe
|
Posted: Thu Jan 17, 2008 7:05 am Post subject: |
|
|
btw, both queries are not equal. |
|
Back to top |
|
|
videlord Beginner
Joined: 09 Dec 2004 Posts: 147 Topics: 19
|
Posted: Thu Jan 17, 2008 1:45 pm Post subject: |
|
|
first of all, different result would be returned by the 2 queries. the execute time may different depend on how may result returned
second, the access path would be the same (most case), index scan, with 3 match columns |
|
Back to top |
|
|
|
|