Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optimize Query

Status
Not open for further replies.

altendew

Programmer
Mar 29, 2005
154
US
This table is creating temporary tables.. is there a better way to execute this..

Code:
 (
SELECT u.id, p.function, u.hotspot, u.psid, u.ord
FROM userHotSpots u, prodSpots p
WHERE u.tid = '68'
AND u.type = 'product'
AND u.psid = p.id
)
UNION ALL (

SELECT u.id, '', u.hotspot, u.psid, u.ord
FROM userHotSpots u, userCustomSpots c
WHERE u.tid = '68'
AND u.type = 'custom'
AND u.psid = c.id
)
ORDER BY ord

Here is the table structures.
Code:
prodSpots
Field Type Null Default 
id   int(20)  No    
pid   int(20)  No  0  
name   varchar(255) No    
function   varchar(255) No    


 Indexes: Keyname Type Cardinality Field 
PRIMARY  PRIMARY  8   id  

--------------------------------------------------------------------------------

userCustomSpots
Field Type Null Default 
id   int(20)  No    
tid   int(20)  No  0  
name   varchar(255) No    
content   longtext No    


 Indexes: Keyname Type Cardinality Field 
PRIMARY  PRIMARY  5   id  

--------------------------------------------------------------------------------

userHotSpots
Field Type Null Default 
id   int(20)  No    
tid   int(20)  No  0  
psid   int(20)  No  0  
hotspot   enum('none', 'underLogo', 'rightLogo', 'top', 'left', 'right') No  none  
type   enum('product', 'custom') No  product  
ord   int(20)  No  0  

 Indexes: Keyname Type Cardinality Field 
PRIMARY  PRIMARY  253   id  
sid  INDEX  42   tid  
tid  INDEX  253   tid,type,psid

Any help would be great.
Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top