Andy Smith <[EMAIL PROTECTED]> wrote: > I have quiet a few queries similar to this doing multiple Left Joins > and > they run extremely slow > 6 secs. Is there a better way to be writing > the below query for sqlite. > > > > SELECT a.id, a.title, a.type, a.dateAdded, a.url, a.path, > a.containerID, a.mimeType, a.width, a.height, a.genreID, > a.thumbnailID, > a.releaseYearID, a.artistID, w.title AS containerName, x.title AS > genreName, y.title AS releaseYearName, z.title AS artistName FROM > mediaitem AS a LEFT JOIN mediaitem AS b ON b.containerID=a.containerID > LEFT JOIN container AS w ON w.id=a.containerID LEFT JOIN container AS > x > ON x.id=a.genreID LEFT JOIN container AS y ON y.id=a.releaseYearID > LEFT > JOIN container AS z ON z.id=a.artistID WHERE a.type=1 AND b.type=0 AND > b.title LIKE 'Opus%' ESCAPE '\' ORDER BY a.title, a.id LIMIT 0,9;
There's no point to use LEFT JOIN between a and b. Your WHERE clause discards all records where b fields are NULLs anyway. See if changing it to plain old JOIN helps. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users