MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 7th, 2014, 01:47 PM
clem_c_rock clem_c_rock is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 22 clem_c_rock User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 11 m 10 sec
Reputation Power: 0
Optimizing this join query

Hello,
I have this query and I cannot figure out how to optimize this query any further. Since itís a joined query, I canít seem to get it to honor any of the indexes.

Hereís the monstrosity:

Code:
SELECT 
	*
FROM assets_products ap 
	INNER JOIN assets a1 ON ap.asset_id=a1.id 
	INNER JOIN products p1 ON ap.product_id = p1.id 
WHERE (p1.name LIKE '%9780203506561%' OR a1.isbn LIKE '%9780203506561%' OR a1.e_isbn LIKE '%9780203506561%' OR REPLACE(a1.isbn, '-','') LIKE '%9780203506561%' OR a1.isbn_10 LIKE '%9780203506561%' OR a1.isbn_13 LIKE '%9780203506561%' OR a1.print_isbn LIKE '%9780203506561%' OR a1.isbn_canonical LIKE '%9780203506561%' OR p1.sku LIKE '%9780203506561%' OR p1.sku_canonical LIKE '%9780203506561%' OR REPLACE(p1.sku, '-','') LIKE '%9780203506561%' OR (a1.author_name LIKE '%9780203506561%' OR a1.author_first_name LIKE '%9780203506561%' OR a1.author_last_name LIKE '%9780203506561%' OR p1.author_name LIKE '%9780203506561%')) AND 
((p1.type !='package') AND ( (a1.build_status NOT IN ('destroyed', 'unavailable', 'out_of_distribution', 'limited_distribution')) AND 
(a1.cached_product_in_store=1 AND a1.block_search!=1 AND a1.type='VitalBook') )) 
GROUP BY p1.id


and the explain that goes with it:
Code:
+----+-------------+-------+--------+-------------------------------------------------------------------------------------------------+--------------------------------+---------+--------+---------------------------------------------------------------------+
| id | select_type | table | type   | possible_keys                                                                                   | key                            | key_len | rows   | Extra                                                               |
+----+-------------+-------+--------+-------------------------------------------------------------------------------------------------+--------------------------------+---------+--------+---------------------------------------------------------------------+
|  1 | SIMPLE      | a1    | ref    | PRIMARY,type                                                                                    | type                           | 93      | 153338 | Using index condition; Using where; Using temporary; Using filesort |
|  1 | SIMPLE      | ap    | ref    | assets_products_asset_id_index,assets_products_pro  duct_id_index                                 | assets_products_asset_id_index | 4       |      1 | NULL                                                                |
|  1 | SIMPLE      | p1    | eq_ref | PRIMARY,sku,products_public_id_index,sku_id_type,i  d_lock,in_store,index_products_on_created_on	| PRIMARY                        | 4       |      1 | Using where                                                         |
|  	 |       			 |    	 |  			| products_parent_id_type,index_products_on_sku_cano  nical,index_products_on_company_id, 					| 	                        		 |         |        | 						                                                        |
|  	 |       			 |     	 | 			  | index_products_on_created_on,index_products_on_upd  ated_on, index_products_on_updated_on         |                                |         |        |						                                                          |
+----+-------------+-------+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


Any help would be greatly appreciated.

Clem C

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Optimizing this join query


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap