I have 80k plus customers and having 4 groups. Now I want to find 2 groups users with a query in mysql. My query is like below:
select c.customers_firstname as recipient_firstname,
c.customers_lastname as recipient_lastname,
c.customers_id as recipient_id,
c.customers_email_address as recipient_email_address
from customers c
where customers_group_id = '1' OR customers_group_id = '3'
When I run this query in phpmyadmin I got the result : Showing rows 0 - 29 ( 59,815 total, Query took 0.0034 sec)
But when I added order by ORDER BY recipient_firstname ASC
in this query the result time is : Showing rows 0 - 29 ( 59,815 total, Query took 0.2607 sec)
the order by query is taking too much time for the result.
I want to reduce the time of order by query.
Please help if there is another way to get the same result in less time.