Ask a Question related to MySQL, Design and Development.
-
howachen@gmail.com #1
Is left-join faster then inner join?
Some people said that using left-join is generally faster than inner
join, is that true?
Thanks...
howachen@gmail.com Guest
-
Left Outer Join
Hi, I have noticed when I do a Left Outer Join in short form that many rows become missing as result of null values. i.e Left Outer Join... -
left join limit 1
I have 3 tables, one main table, and two tables that reference the first table. the two reference tables may have more than one entry to the first... -
Left join isn't joining
Hello, I've got a select statement that joins two tables. -- tblPageHitCalendar contains a single column holding dates. It has every day since... -
PHP/MySQL Left Join Question
CM: Finally getting back to this and maybe being in the middle of a bad flu ain't helping, but I'm not getting the names to print and am wondering... -
left join problem
if you just need something unique in the result set, 1. combination (NJIDATA.GLPMSTR.ID, NJIDATA.GLPMTRN.ID) is unique 2. you could also use... -
Axel Schwenke #2
Re: Is left-join faster then inner join?
[email]howachen@gmail.com[/email] wrote:
Again: some people may be stupid.> Some people said that using left-join is generally faster than inner
> join, is that true?
LEFT JOIN and INNER JOIN are different things. You cannot compare them.
If you write an INNER JOIN as LEFT JOIN you will either end up with
different results or - if you filter the NULL rows of the LEFT JOIN -
there is good chance for the LEFT JOIN to be slower. Because:
- the LEFT JOIN creates extra intermediate data (the NULL rows for
unmatched rows from the left table) that is thrown away later
- the optimizer has less freedom to optimize the LEFT JOIN
XL
--
Axel Schwenke, Senior Software Developer, MySQL AB
Online User Manual: [url]http://dev.mysql.com/doc/refman/5.0/en/[/url]
MySQL User Forums: [url]http://forums.mysql.com/[/url]
Axel Schwenke Guest
-
howachen@gmail.com #3
Re: Is left-join faster then inner join?
Axel Schwenke 寫道:
If the "NULL values problem" can be ignored, is that left-Join faster> [email]howachen@gmail.com[/email] wrote:>> > Some people said that using left-join is generally faster than inner
> > join, is that true?
> Again: some people may be stupid.
>
> LEFT JOIN and INNER JOIN are different things. You cannot compare them.
>
> If you write an INNER JOIN as LEFT JOIN you will either end up with
> different results or - if you filter the NULL rows of the LEFT JOIN -
> there is good chance for the LEFT JOIN to be slower. Because:
>
> - the LEFT JOIN creates extra intermediate data (the NULL rows for
> unmatched rows from the left table) that is thrown away later
>
> - the optimizer has less freedom to optimize the LEFT JOIN
>
>
> XL
> --
> Axel Schwenke, Senior Software Developer, MySQL AB
>
> Online User Manual: [url]http://dev.mysql.com/doc/refman/5.0/en/[/url]
> MySQL User Forums: [url]http://forums.mysql.com/[/url]
than inner join?
howachen@gmail.com Guest
-
Luuk #4
Re: Is left-join faster then inner join?
<howachen@gmail.com> schreef in bericht
news:1149948666.324312.166230@h76g2000cwa.googlegr oups.com...
Axel Schwenke ??:
If the "NULL values problem" can be ignored, is that left-Join faster> [email]howachen@gmail.com[/email] wrote:>> > Some people said that using left-join is generally faster than inner
> > join, is that true?
> Again: some people may be stupid.
>
> LEFT JOIN and INNER JOIN are different things. You cannot compare them.
>
> If you write an INNER JOIN as LEFT JOIN you will either end up with
> different results or - if you filter the NULL rows of the LEFT JOIN -
> there is good chance for the LEFT JOIN to be slower. Because:
>
> - the LEFT JOIN creates extra intermediate data (the NULL rows for
> unmatched rows from the left table) that is thrown away later
>
> - the optimizer has less freedom to optimize the LEFT JOIN
>
>
> XL
> --
> Axel Schwenke, Senior Software Developer, MySQL AB
>
> Online User Manual: [url]http://dev.mysql.com/doc/refman/5.0/en/[/url]
> MySQL User Forums: [url]http://forums.mysql.com/[/url]
than inner join?
When there is 180 km/h on the speedometer of my car, can i do 180 km/h?
NO,
Maybe you get the same results, but bevause of differen functionallity you
should NOT do this! (like Axel said)
Luuk Guest
-
Dikkie Dik #5
Re: Is left-join faster then inner join?
I think others in this thread have given enough answer already.
A former colleague of me told that there was a time when MySQL supported
left joins but not inner joins. Anyway, that was his explanation for
the enormous quantities of left joins in the code that should really
have been inner joins.
There are a few things to say about this.
First, the only way to be sure is to test it.
Second, if the query is not a performance bottleneck anyway, it may a
good to optimize it for legibility. If code is not absolutely clear, it
is a maintenance problem that needs to be fixed.
Third, as an object-oriented programmer, I find lazy collections faster
than joins. Especially because the collections can optimize their
database "strategy": Some of them use SELECT statements, others use
HANDLER statements. Some are greedy (load all in one go), some are lazy
(load something only when needed), and some can be scheduled, so that
anything not needed this microsecond can be read in the next batch.
Anyhow, no data is read more than once in a page building session. Off
course, these optimizations all reside inside the table wrapper classes,
and have little to no effect on the surrounding code.
Best regards
[email]howachen@gmail.com[/email] wrote:> Some people said that using left-join is generally faster than inner
> join, is that true?
>
> Thanks...
>Dikkie Dik Guest
-
Saeed #6
Re: Is left-join faster then inner join?
with my experience I say yes. I have a product table with 12 reference fields and 1000 records. it took about 16 secs to fetch data from that table but when I changed all jions to left join it's duration changed to 0.125 sec! and also I need the null fields so the result was OK for my problem. it was same for right join but result wasn't the one I expected.
Saeed Guest



Reply With Quote

