Dave Blake wrote:
> 3) SELECT song.*, song_artist.*, artist.*
> FROM song LEFT JOIN song_artist ON song.idSong = song_artist.idSong
> JOIN artist ON song_artist.idArtist = artist.idArtist
> WHERE song.idSong =1
>
> This ... has the same join combination as 1).

No.
1) has "song LEFT JOIN (song_artist JOIN artist)".
3) has "(song LEFT JOIN song_artist) JOIN artist".

> Similarly trying a view using outer join
>
> CREATE VIEW songartistleftview AS SELECT song_artist.idSong AS idSong,
> song_artist.idArtist AS idArtist,
> artist.strArtist AS strArtist
> FROM song_artist LEFT JOIN artist ON song_artist.idArtist = artist.idArtist
>
> New query
> 4) SELECT song.*, songartistleftview.* FROM song
> LEFT JOIN songartistleftview ON song.idSong = songartistleftview.idSong
> WHERE song.idSong =1
>
> 4) has same slow query plan as 1) despite having all left joins like 2).

There are still differences:
2) has "(song LEFT JOIN song_artist) LEFT JOIN artist".
4) has "song LEFT JOIN (song_artist LEFT JOIN artist)".


Regards,
Clemens

Reply via email to