It executes in 0 sec when you run it. It might be in the query cache. Try it with SQL_NO_CACHE. But even then it might run faster than it did when it got logged in the slow log, because the table's data might be in memory and therefore faster to access.
The point is that the slow query log shows you how long the statement took to execute at the time of logging. It doesn't say anything about how fast the query will execute at other times, or WHY it was a long query at the time of logging. It could be a lot of things including locking, other queries running at the same time, a background Patrol Read on your RAID controller, etc. That's why I asked you to paste the slow query log entry for this query. On Fri, Jan 2, 2009 at 12:14 AM, Ananda Kumar <anan...@gmail.com> wrote: > mysql> explain SELECT SUM(COUNTER_VALUE) FROM STO_LIS sl, > -> SCAT_LIS sfl WHERE sl.STO_LIS_ID = > -> sfl.LIS_ID AND sfl.CAT_ID = '-1'; > > +----+-------------+-------+------+-----------------------+-------------------+---------+---------------------+------+-------------+ > | id | select_type | table | type | possible_keys | > key | key_len | ref | rows | Extra | > +----+-------------+-------+------+-----------------------+-------------------+---------+---------------------+------+-------------+ > | 1 | SIMPLE | sfl | ref | PRIMARY,sfcatlist_lst | > PRIMARY | 4 | const | 23 | Using index | > | 1 | SIMPLE | sl | ref | STO_LIST_UK | STO_LIS_UK | 4 | > sm15.sfl.lis_id | 1 | Using where | > +----+-------------+-------+------+-----------------------+-------------------+---------+---------------------+------+-------------+ > 2 rows in set (0.31 sec) > > mysql> SELECT SUM(COUNTER_VALUE) FROM STORES_LISTING sl, > SFCATEGORY_LISTING sfl WHERE sl.STORES_LISTING_ID = sfl.LISTING_ID AND > sfl.CATEGORY_ID = '-1'; > +--------------------+ > | SUM(COUNTER_VALUE) | > +--------------------+ > | NULL | > +--------------------+ > 1 row in set (0.00 sec) > > > > On 12/31/08, Baron Schwartz <ba...@xaprb.com> wrote: >> >> Hi, >> >> On Wed, Dec 31, 2008 at 8:44 AM, Ananda Kumar <anan...@gmail.com> wrote: >> > Hi All, >> > I have enabled slow query log. >> > Generally this file will have sql's which take more than long-query time >> > to >> > execute and also sql's not using indexes. >> > But i see sql's which does not come under the above condition. >> > I have set the long-query time to 1 Sec . >> > >> > The query takes less than 1 sec to execute and also uses indexes, but >> > still >> > its recored in slow query log. >> >> What is the execution time shown in the slow query log? >> >> What is the query? >> >> If you can paste the whole log entry here, that would be good. >> >> >> -- >> Baron Schwartz, Director of Consulting, Percona Inc. >> Our Blog: http://www.mysqlperformanceblog.com/ >> Our Services: http://www.percona.com/services.html > > -- Baron Schwartz, Director of Consulting, Percona Inc. Our Blog: http://www.mysqlperformanceblog.com/ Our Services: http://www.percona.com/services.html -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org