On Wednesday 16 June 2004 21:12, Omer Zak wrote:
> On Wednesday 16 June 2004 12:14, Yuval Yaari wrote:
> > Hi,
> >
> > I had a query that used JOIN and took too much time (4 seconds).
> > I figured Perl could handle it much faster, and so it did.
>
> While Perl may be doing it faster, I'd suggest that you check why your
> JOIN took excessively long time.  Properly defined tables and JOINs should
> execute faster in MySQL, when optimized, than in Perl.  Maybe you were
> missing an index, or used suboptimal join order?
>
> To investigate this, you may want to use the EXPLAIN SELECT command.  This
> command causes MySQL to output a table telling you how it would actually
> execute the SELECT command.  You'll see whether it needs to examine
> excessively large number of rows in the tables, and whether adding an
> index can improve SELECT performance while not degrading too much
> INSERT/DELETE performance.
>
>                                              --- Omer
> My opinions, as expressed in this E-mail message, are mine alone.
> They do not represent the official policy of any organization with which
> I may be affiliated in any way.
> WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html
>
>
> =================================================================
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
Hi,

I don't know from where this email came, if I had the original email I could 
have maybe seen if there was a mistake in the query. In any case MySQL does 
optimizations to the queries, and these optimizations aren't always good, for 
example for UNION and INNER JOINS, so if your Perl does it quicker its only 
because the query is probably not written correctly.

One good example is not to use UNION and INNER JOIN too many times in the same 
query, but rather place the results inside a temporary HEAP TABLE you create 
(in SQL syntax there is support for it), and then requery this HEAP table.

-- 
Thanks
Noam Rathaus
CTO
Beyond Security Ltd.

Join the SecuriTeam community on Orkut:
http://www.orkut.com/Community.aspx?cmm=44441

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to