On 3/2/12 8:31 AM, "Simon Davies" <simon.james.dav...@gmail.com> wrote:
>On 2 March 2012 16:23, Duquette, William H (318K) ><william.h.duque...@jpl.nasa.gov> wrote: >> Howdy! >> >> Suppose I have two related tables, t1 and t2, and I write a view like >>this: >> >> CREATE VIEW myview AS SELECT * FROM t1 JOIN t2 USING (some_column); >> >> If I am querying data just from t1, is there a performance penalty for >>using myview in the query? Or will the query planner generate >>approximately the same bytecode as it would if I'd simply queried t1? >> >> -- >> Will Duquette -- william.h.duque...@jpl.nasa.gov > >SQLite version 3.6.11 >Enter ".help" for instructions >sqlite> create table t1( id integer primary key, data text ); >sqlite> create table t2( id integer primary key, data text ); >sqlite> >sqlite> create view v1 as select t1.id as id, t1.data as d1, t2.data >as d2 from t1 join t2 on t1.id=t2.id; >sqlite> >sqlite> >sqlite> explain query plan select data from t1 where id>10; >0|0|TABLE t1 USING PRIMARY KEY >sqlite> explain query plan select d1 from v1 where id>10; >0|0|TABLE t1 USING PRIMARY KEY >1|1|TABLE t2 USING PRIMARY KEY >sqlite> > >It seems not for v 3.6.11 OK, so it's going to look up the id in both tables whether it needs to or not...because, given that it's an inner join, you don't get the record from t1 unless there's a matching record in t2. Got it! Thanks! > >Regards, >Simon >_______________________________________________ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users