Hi,
ich brauche Hilfe bei der besseren Formulierung eines Queries. Im Moment ist das ganze absolut inperformant. Ich versuche folgendes:
Es handelt sich dabei um ein Query, welches Filter für einen Onlineshop darstellt und pro Filter ein neues INNER JOIN braucht. Leider wird das ganze ab dem dritten Filter absolut inperformant (Exponentiell zunehmende Ausführzeit). Ohne die OR-Kondition funktioniert alles sehr schnell. Ich brauche also eine alternative Formulierung wenn dies möglich ist. Leider bekomme ich das im Moment nicht hin
Hier mal noch ein konkretes Beispiel, welches meinen Fall mit 3 Filtern zeigt:
Diese Abfrage dauer 13 Sekunden und es sollte möglich sein, auch bis zu 12 Filter zu verwenden. Bereits bei 4 Filtern wird das jedoch eine minutendauernde Abfrage.
ich brauche Hilfe bei der besseren Formulierung eines Queries. Im Moment ist das ganze absolut inperformant. Ich versuche folgendes:
PHP-Code:
SELECT *
FROM a
INNER JOIN b
ON b.id = a.id
OR a.id NOT IN(600,641,622)
INNER JOIN c
ON c.id = a.id
OR a.id NOT IN(600,641,622)
...
Hier mal noch ein konkretes Beispiel, welches meinen Fall mit 3 Filtern zeigt:
PHP-Code:
SELECT DISTINCT 1 AS `status`, `e`.`entity_id`, `e`.`type_id`, `e`.`attribute_set_id`, `cat_index`.`position` AS `cat_index_position`, `e`.`name`, `e`.`description`, `e`.`price`, `e`.`small_image`, `e`.`tax_class_id`, `e`.`url_key`, `e`.`thumbnail`, `e`.`short_description`, `e`.`special_price`, `e`.`special_from_date`, `e`.`special_to_date`, `e`.`news_from_date`, `e`.`news_to_date`, `e`.`required_options`, `e`.`price_type`, `e`.`weight_type`, `e`.`price_view`, `e`.`shipment_type`, `e`.`image_label`, `e`.`small_image_label`, `e`.`thumbnail_label`, `e`.`links_purchased_separately`, `e`.`msrp_enabled`, `e`.`msrp_display_actual_price_type`, `e`.`msrp`, `e`.`links_exist`, `e`.`cf_marke`, `e`.`cf_marke_value`, `e`.`cf_marke_modell`, `e`.`cf_marke_modell_value`, `e`.`cf_baujahr`, `e`.`cf_baujahr_value`, `e`.`cf_marke_modell_baujahr_radio`, `e`.`cf_marke_modell_baujahr_radio_value`, `e`.`cf_ma_mo_ba_ra_sound`, `e`.`cf_ma_mo_ba_ra_sound_value`, `e`.`cf_ma_mo_ba_ra_pdc`, `e`.`cf_ma_mo_ba_ra_pdc_value`, `e`.`cf_ma_mo_ba_ra_so_pd_can`, `e`.`cf_ma_mo_ba_ra_so_pd_can_value`, `e`.`cf_marke_modell_baujahr_rfk`, `e`.`cf_marke_modell_baujahr_rfk_value`, `e`.`cf_marke_modell_baujahr_gps`, `e`.`cf_marke_modell_baujahr_gps_value`, `e`.`cf_marke_modell_baujahr_info`, `e`.`cf_marke_modell_baujahr_info_value`, `e`.`cf_marke_modell_baujahr_auxusb`, `e`.`cf_marke_modell_baujahr_auxusb_value`, price_index.price AS `indexed_price`, `price_index`.`price`, `price_index`.`final_price`, IF(`price_index`.`tier_price`, LEAST(`price_index`.`min_price`, `price_index`.`tier_price`), `price_index`.`min_price`) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price` FROM `catalog_product_flat_2` AS `e`
INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=2 AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '418'
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOIN `catalog_product_index_eav` AS `cf_marke_idx` ON cf_marke_idx.entity_id = e.entity_id AND cf_marke_idx.attribute_id = '1037' AND cf_marke_idx.store_id = 2 AND cf_marke_idx.value = '453' OR (e.entity_id NOT IN(600) AND e.cf_baujahr is null AND e.cf_marke is null AND e.cf_marke_modell is null)
INNER JOIN `catalog_product_index_eav` AS `cf_marke_modell_idx` ON cf_marke_modell_idx.entity_id = e.entity_id AND cf_marke_modell_idx.attribute_id = '1038' AND cf_marke_modell_idx.store_id = 2 AND cf_marke_modell_idx.value = '496' OR (e.entity_id NOT IN(600) AND e.cf_baujahr is null AND e.cf_marke is null AND e.cf_marke_modell is null)
INNER JOIN `catalog_product_index_eav` AS `cf_baujahr_idx` ON cf_baujahr_idx.entity_id = e.entity_id AND cf_baujahr_idx.attribute_id = '1039' AND cf_baujahr_idx.store_id = 2 AND cf_baujahr_idx.value = '452' OR (e.entity_id NOT IN(600) AND e.cf_baujahr is null AND e.cf_marke is null AND e.cf_marke_modell is null)
Kommentar