I have a question about a Mysql query.
I have some slow queries. Here is one of them:
SELECT
xxx_accounts.id
, xxx_accounts.name
, xxx_accounts.account_name
, xxx_accounts.address_postalcode
, xxx_accounts.address_city
, xxx_accounts.address_state
, xxx_accounts.date_modified
, xxx_accounts.assigned_user_id
FROM
xxx_accounts
WHERE
xxx_accounts.deleted = 0
ORDER BY
xxx_accounts.date_entered DESC
LIMIT 4434950, 11;
It takes almost 2 minutes even if it use limit query.
Explain is here:
+----+-------------+--------------+------+--------------------------------------------------------------------------------+-------------------------+---------+-------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+--------------------------------------------------------------------------------+-------------------------+---------+-------+---------+-------------+
| 1 | SIMPLE | xxx_accounts | ref | idx_deleted_datemodified,idx_deleted_addresspostalcode,idx_deleted_dateentered | idx_deleted_dateentered | 2 | const | 1861322 | Using where |
+----+-------------+--------------+------+--------------------------------------------------------------------------------+-------------------------+---------+-------+---------+-------------+
This explain said that rows is total count.
However, this SQL is changed limit ""query,LIMIT 1,11"", it takes a few seconds (like 1 or 2 seconds).
The differnce of these SQL is between LIMIT 4434950,11
and LIMIT 1,11
.
Can this problem be solved somehow?