This is maybe an index problem. If not, maybe you can help with
optimizing my query.
Before i created an index for a table the following query ran quick:
select * from table1
where name = 'oscar'
and city = 'amsterdam'
This table1 has -say- 10 million records
Only 10 of them have a name 'oscar'.
But 1 million of records have as city 'amsterdam'.
Again, this select retrieved quickly the result.
Then i (for whatever reason, that is not the point here) made an index
on 'city' on this table.
Now the select above takes very long to produce the same result.
I suspect the server selects the index to produce a
temporary-result-table with one million records (with amsterdam).
So, if that is the case, how can i prevent the server to use this index
for this query.
Then a related question.
I tried to optimize the query, by subquering it myself in the following
way:
select * from (select * from table1 where name = 'oscar' )
where city = 'amsterdam'
But this did not help. It runs as slowly as the other. I cannot
understand this. Do you?
Any help appreciated on optimizing queries (maybe by assinging a
specific sequence of evaluating the where-parts of queries?).
Oscar
--
----------------------------------------------------------------
OMEGAM
Environmental Research Institute
tel: ++31 (0)20 5976 787 fax: ++31 (0)20 5976 777
P.O.Box: 94685, 1090 GR Amsterdam
http://www.omegam.nl
----------------------------------------------------------------