tinys xuefer wrote:

slow.log:
# Query_time: 14 Lock_time: 0 Rows_sent: 30 Rows_examined: 771327
SELECT * FROM `post` LIMIT 771297, 30;
i dp have privmary key on table `post`
does 'Rows_examined: 771327' means mysqlserver read through those 771327 rows to get 30 rows?
it takes 14 seconds!


possible to show 'Rows_examined' in a explain or other commands? slow log is hard to debug..

and possible to optimize?

But you didn't use the primary key! In fact, you didn't ask for any order at all. Mysql does not try to guess that you meant to order by the primary key, it simpply does what you tell it. Your query, in effect, tells mysql to pick 771327 rows from post in any order and send you the last 30. Assuming your primary key column is named id, you need to change this query to


  SELECT * FROM post ORDER BY id LIMIT 771297, 30;

With the explicit ORDER BY on the primary key, mysql will use the index to quickly find the 30 rows you want.

Michael


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



Reply via email to