guest2013-1
guest
- Joined
- Aug 22, 2003
- Messages
- 19,800
- Reaction score
- 13
Here is my select statement:
If I take out the red part, this is my EXPLAIN:
WITH the red part, it gives me this:
Now I've tried all combinations of index's on the xml_record_supplier table. I just can't seem to figure out why this screws up so badly. Any ideas?
Code:
select
xml_record_product.product_id,
IfNull(xml_record_product.product_short_description,xml_record_product.product_description) AS BookDescription,
xml_record_product.product_image,
xml_record_product.product_publisher_name AS Publisher,
xml_record_product.product_title AS BookTitle,
xml_record_product.product_form,
xml_record_product.product_num_pages,
xml_record_product.product_BASICMainSubject,
xml_record_product.product_BICMainSubject,
xml_record_product.product_audience_code,
xml_record_product.product_country_of_publication,
xml_record_product.product_publishing_status,
xml_record_product.product_publication_date AS BookDate,
xml_record_product.product_imprint,
xml_record_product.product_active,
xml_record_product.product_isFeatured,
xml_record_product.product_isNewArival,
xml_record_product.product_short_description,
xml_record_product.product_description,
xml_record_product.product_isbn13 AS ISBN,
xml_record_subject.subject_heading_text
FROM xml_record_product
inner join xml_record_contributor ON xml_record_product.product_id = xml_record_contributor.product_id
inner join xml_record_subject on xml_record_contributor.product_id = xml_record_subject.product_id
[color=red]inner join xml_record_supplier on xml_record_product.product_id = xml_record_supplier.product_id AND supplier_price > 0[/color]
where contributor_title like '%josh%'
order by xml_record_product.product_publication_date DESC limit 20;
If I take out the red part, this is my EXPLAIN:
Code:
SIMPLE xml_record_product index PRIMARY pub_date 265 20
SIMPLE xml_record_subject ref product_id_sub product_id_sub 8 mysupplier1.xml_record_product.product_id 1
SIMPLE xml_record_contributor ref cont_product_id cont_product_id 8 mysupplier1.xml_record_subject.product_id 1 Using where
WITH the red part, it gives me this:
Code:
SIMPLE xml_record_supplier index sup_product_id sup_product_id 265 895424 Using where; Using index; Using temporary; Using filesort
SIMPLE xml_record_subject ref product_id_sub product_id_sub 8 mysupplier1.xml_record_supplier.product_id 1
SIMPLE xml_record_product eq_ref PRIMARY PRIMARY 8 mysupplier1.xml_record_supplier.product_id
SIMPLE xml_record_contributor ref cont_product_id cont_product_id 8 mysupplier1.xml_record_subject.product_id 1 Using where
Now I've tried all combinations of index's on the xml_record_supplier table. I just can't seem to figure out why this screws up so badly. Any ideas?