I have a bit of an odd situation and I'm trying to understand it.
I have two tables, I'll list the necessary fields.
products [MyIsam -- due to full text search]
product_id [primary index]
Has roughly 1,000,000 rows in it.
website_products [InnoDB]
website_id [primary]
product_id [primary]
Has roughly 6,000,000 rows in it.
Now when I do queries...
SELECT
COUNT(`product_id`)
FROM `products`
Returns in 0.109 seconds with the result "1030650"
SELECT
COUNT(wp.`product_id`)
FROM `website_products` AS wp
WHERE wp.`website_id` = 1133
Returns in 0.577 seconds with the result "104150"
SELECT
COUNT(wp.`product_id`)
FROM `website_products` AS wp
LEFT JOIN `products` AS p ON p.product_id = wp.product_id
WHERE wp.`website_id` = 1133
Returns in 38.173 seconds with result "104150"
An EXPLAIN SELECT yields:
1 SIMPLE wp ref PRIMARY,website_id PRIMARY 4 const 204392 Using index
1 SIMPLE p eq_ref PRIMARY PRIMARY 4 imaginer_system.wp.product_id 1 Using index
Why is it so much longer when I join the table? How can I reduce that?