Fetch correct stats from database I am trying to get count of all quiz users who have made purchases. Main table for storing users is user and quiz_client is linked with user table. sales_order table holds data of users who have placed orders/made purchases.

I'm running the below query but it's taking forever, is there something wrong with the query?

SELECT 
    COUNT(user.id)
FROM
    cx_user
        JOIN
    quiz_client ON quiz_client.user_id = user.id
        JOIN
    sales_order ON user.email = sales_order.customer_email
Change to

COUNT(DISTINCT user.id)


Else you are counting "purchases", not "users".