when I use a MySQL query:
SELECT count(*) FROM orders
it takes 0.183 s
if I use the query:
SELECT count(*) FROM orders
LEFT JOIN order_items ON (`orders`.`StoreOrderId` = order_items.StoreOrderId)
LEFT JOIN seller_accounts ON (`orders`.`seller_id` = seller_accounts.seller_id)
it takes 4.793 s
after explain:
{table:orders, select_type:simple, type:index, key_len:166, rows:841683, extra:using index}
{table:seller_accounts, select_type:simple, type:ref, key_len:83, rows:1, extra:using index}
{table:order_items, select_type:simple, type:ref, key_len:83, rows:1, extra:using index}
this count() query is used for PHP pagination, I need to know how many records are in the database so that I can know how many pages.
but count() query took me 4.793s, which is too long, who can I make it faster?