Optimizing Queries with EXPLAIN
Posted by: george george
Date: May 16, 2007 08:31PM

greenhorn database designer with newbie question. In the query returned by "explain select" I received an TYPE:"ALL" for the 1st table. As I understand it, this is something that needs to be corrected. But I'm having trouble getting rid of it even by creating extra indexes to help with the JOIN. here are simplified versions of tables in question.

/********************** table property *************************/

property (

id INT NOT NULL AUTO_INCREMENT,
address char(50)
)


/********************** table deals *************************/

deals (

property_id INT,
deal_type_id INT,

sales_pitch TEXT,
price INT,

INDEX (sales_pitch(10), price),
PRIMARY KEY (property_id, deal_type_id)
)

/********************** query *************************/

EXPLAIN

SELECT

deals.property_id,
deals.price,
deals.sales_pitch,

property.address

FROM

deals LEFT JOIN property

ON

deals.property_id = property.id


/********************************************************/

What baffles me the most is that if I leave out (deals.sales_pitch) in the SELECT statement, then EXPLAIN returns a TYPE:"INDEX". But if i have deals.sales_pitch under SELECT statement EXPLAIN returns a TYPE:"ALL". Can someone please help me understand why this happens, when i have already created a multi-column index containing both (sales_pitch(10), price). THanks very much in advance. Also i would like to know if TYPE:"INDEX" is the best thing one can hope for in this type of query. THank you

Options: ReplyQuote


Subject
Written By
Posted
Optimizing Queries with EXPLAIN
May 16, 2007 08:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.