Unless your WHERE clause includes relationships for all the tables, you are dealing with a Cartesian product - that is always slow.
And if you do have all the relationships included, this is still a monster query. Do you have the proper indexes defined? Do you really need to join these 5 tables in the query? Based on your description, it is hard to tell what you are really trying to do, and what would be the best way to do it. HTH, Tore. ----- Original Message ----- From: "Ferhat BINGOL" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, February 22, 2003 9:21 AM Subject: big table, slow queries...??? > Hi, > > I am new at this group. Nowadays I am using PHP/MySQL more than ever. I have > a problem with making queries on my huge database (totally more than 20 > million rows and 9 GB). > > The main problem is it is rather slow. For example I am making a query which > is checking the 5 biggest tables for, from 2 "where" options to 20. I am > using something like that; > > SELECT > table1.field1, > table1.field2, > table1.field3, > table2.field2, > table3.field2, > table4.field1, > table5.field1, > table5.field2 > FROM > table1, > table2, > table3, > table4, > table5 > WHERE > (table1.field1=table2.field1) AND > (table3.field4 BETWEEN case1 AND case2) > .... > > (Where statement is longer than this) > > > and so on. I think you understand the structure I use for making queries. > But it is too slow. I mean I was expecting to be faster. > > Can you advice me a different kind of query string? I read some articles > about using JOIN, GROUP or so on. But I am little bit confused about it. > > What is the best way to make queries on big table? > > Thanks, > FERHAT > > > P.s : I am using MySQL 3.23 and PHP/Apache on a Windows XP machine. 386 MB > RAM with Pentium3 350. > > > > Ferhat > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php