At 12:53 PM 11/7/2005, you wrote:
Hi,

I have tried:

mysql> select count(*) from table_name where date='2005-11-07' and id=11;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (46.42 sec)

As you may see, this query took more than 46 seconds and I don't know why.
I am the single person that was using the database in the moment I've made
that query, and there are no programs that use to lock the tables until
finishing some other queries anyway.

The table has an index on the data field and another index on the id field,
and usually takes much less time for such a query.

This database is used in a web site and I see sometimes that it takes a very
long time for displaying some pages and now I know that the problem is the
database.

The version of MySQL which is installed on the computer I work is:
4.1.5-gamma-standard-log

I know it could be a little older, but this could be the only problem? (and
the fact that is a gamma version?)

Thank you.

Teddy

Teddy,
Chances are it is using only 1 of the indexes. You will get much faster results if you use a compound index made up of both the date & id fields. (So add the Id field to the end of the existing Date index).

Mike



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


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

Reply via email to