Re: Choosing Indices
Posted in 1996
Joseph Kormann writes:
->
->Is there a way to choose the main index that you want to search on?
->
->If I have a where clause with two statements. Both statements have their
->own indices. Problem is I want the query to run the initial index off the
->second statment, then subquery to the first statement.
->
->I've tried reversing the statment order, but SQL still does it the same
->way. Any help?
There are a couple of things you can try.
(1) Attempt to force the index to be used. Sometimes adding a redundant
condition to a where clause using a greater than symbol might help. Or
variations of this method (sometimes you just need to play around with
it. For example, instead of:
select * from your_table
where first_index = "X" and
second_index = "Y"
try:
select * from your_table
where first_index >= "A" and
first_index = "X" and
second_index = "Y"
(2) You can always use multiple select statements saving intermediate results
in temp tables. For example, change from:
select * from your_table
where first_index = "X" and
second_index = "Y"
to:
select * from your_table
where first_index = "X"
into temp t1 with no log;
select * from t1
where second_index = "Y"
into temp t1 with no log;
Good luck!
Regards,
- Cathy
--------------------------------------------------------------------------------
Cathy Kipp e-mail: ckipp@vth1.vth.colostate.edu Phone: (970) 491-1294
Colorado State University Veterinary Teaching Hospital Fax: (970) 491-1205