Hi,

up to now my idea of how MySQL uses indexes was, that when I have a WHERE
clause with several fields and I have an index on each field, MySQL chooses
one index (from which it thinks that it will return the fewest rows when
matched again the condition) and uses this index to "select" a couple of
rows based on that one index. Then it scans all these rows and matches every
row against the conditions in the WHERE clause, without using any other
index.

But now I observed the following:

When I ran a simple query (one table only, no joins) with a WHERE clause
with several columns, it took more than one minute (60000 rows, 500 MB).
Then I added indexes and ran the query after adding each index. There was
almost no change in execution time.
But when I added the last index (so all columns that were in the WHERE
clause had indexes) the query suddenly  took under one second.
Then I removed all the indexed, one by one, but I can't make the query take
more than one second again. Even when I restart the mysql daemon, it still
takes only a few milliseconds.

So I have two questions:
1. What happended?
2. Does it really make sense to have single indexes per column when the
columns are used together in one WHERE clause?

Best regards,
André


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to