[ Date Index ][
Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
On Thu, 15 Jul 2004, John Daragon wrote:
On Wednesday 14 July 2004 08:48, Robin Cornelius wrote:You need an outer join. Eg. SELECT pinksheet.requirment,contact.phone,contact.fax FROM contact LEFT JOIN pinksheet ON contact.PKey = pinksheet.contactidThat works perfectly, thanks! It seems to require a lot of horsepowerUh-oh...
Indeed. You want to use explain $query in the mysql shell, this will give you some information about whether it is using indexes and has to use temporary tables, etc. You probably also want to read the section in the Mysql manual on optimising queries which explains how to check the indexes are being used correctly and also try 'show index from tablename' which will tell you want indexes you have on a table. This is a fairly common query, and it should be pretty easy for the database - in fact it is pretty much MySQL's bread-and-butter. If you have indexed the tables correctly and ensure the query uses them if possible (sometimes, it won't use an index, i.e. if it is looking for more than 30% of a table), also restricting the results is key, as it makes the data sets that the RDBMS has to compare smaller (and it is more likely to be able to use the indexes). The MySQL manual explains it all pretty well. cheers, A. -- Aaron J Trevena - Perl Hacker, Kung Fu Geek, Internet Consultant AutoDia --- Automatic UML and HTML Specifications from Perl, C++ and Any Datasource with a Handler. http://droogs.org/autodia -- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe.