On Wednesday, May 30, 2012 11:29:00 f.h. Black, Michael (IS) wrote:
> Since you have a one-to-one relationship I'm not sure why you don't just
> put the inseam with the Employee, but perhaps you're just giving an
> example here.
It is an example.

> 
> I would do it this way which is going to run a heck of lot faster than
> using string compares as you are doing.
Perhaps it runs faster, but it still does the unnecessary search into right-
hand table:
sqlite> explain query plan select name from employee inner join Uniform on 
employee.id=uniform.employeeid;
0|0|0|SCAN TABLE employee (~1000000 rows)
0|1|1|SEARCH TABLE Uniform USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)

(this actual query goes into a view that I make available to app's 
"customers")

> Or do this which I think does exactliy what you are thinking...
> sqlite> select name from Employee where id in (select employeeid from
> Uniform);

Nope, that's effectively a inner join instead of an outer join.

Charles
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to