Re: optimizing a select statement over a database with 50 million recs

2004-02-29 Thread karthik viswanathan
here is the updated select statement i came with but still needs improvement SELECT Distinct (a.id) From table1 a INNER JOIN table1 b USING ( p_id ) INNER JOIN table2 c USING ( p_id ) INNER JOIN table3 d USING ( out_id ) INNER JOIN table4 e ON ( d.name_id = e.name_id ) INNER JOIN table4 f

RE: optimizing a select statement over a database with 50 million recs

2004-02-29 Thread Donny Simonton
Can you send us a new explain on this version? Donny -Original Message- From: karthik viswanathan [mailto:[EMAIL PROTECTED] Sent: Sunday, February 29, 2004 4:12 PM To: [EMAIL PROTECTED] Subject: Re: optimizing a select statement over a database with 50 million recs here is the

RE: optimizing a select statement over a database with 50 million recs

2004-02-29 Thread karthik viswanathan
Thanks for looking at my problem. here is the explain for this version of select b | ref | id,p_id,combine | combine | 4 | const | 5281 | Using where; Using index; Using temporary | c | eq_ref | PRIMARY,p_id | PRIMARY | 4 | b.p_id | 1 | | | d | ref | name_id,out_id | out_id | 4 | c.out_id |

RE: optimizing a select statement over a database with 50 million recs

2004-02-29 Thread Donny Simonton
From looking at this, you have a using temporary, on table b. Which may be the biggest slow down, it's hard to somewhat tell. I assume you have indexes on everything... I'm not sure where you are running explain from, but when I run one it looks like below. You can easily see where problems

RE: optimizing a select statement over a database with 50 million recs

2004-02-29 Thread karthik viswanathan
Here is the command line explain, earlier i had used phpAdmin +-++-+--+-+--- --+--+---+ | table | type | possible_keys | key |

RE: optimizing a select statement over a database with 50 million recs

2004-02-29 Thread Donny Simonton
So if this is your query and based on the explain this is what I would recommend. SELECT Distinct (a.id) From table1 a INNER JOIN table1 b USING ( p_id ) INNER JOIN table2 c USING ( p_id ) INNER JOIN table3 d USING ( out_id ) INNER JOIN table4 e ON ( d.name_id = e.name_id ) INNER JOIN table4