"Brandon, Nicholas (UK)" <[EMAIL PROTECTED]> wrote:
> > >  select ....
> > >  FROM instances as i
> > >    inner join instance_fields as count using(instanceid)
> > >    inner join instance_fields as first using (instanceid)
> > >    inner join instance_fields as last using (instanceid)
> > >    inner join instance_fields as severity using (instanceid)
> > >    inner join instance_fields as summary using (instanceid)
> > >    inner join instance_fields as node using (instanceid)
> > >    inner join instance_fields as source using (instanceid)
> 
> I don't want to hijack this thread (not too much anyway) but this got me
> thinking about JOINs since I have a database that uses a similar concept
> (one table holds a number of key-value pairs for another).
> 
> As I understand it, an INNER JOIN is equivalent in pseudo-code to:
> 
> For (every record in table A)
>    for (every record in table B)
>       for (...)
> 
> where another for loop is added with each additional JOIN.
> 
> Using Christian's example, would SQLite use the pseudo-code represented
> above or does it use some intelligence that all the JOINs are from the
> same table and hence the pseudo-code is:
> 
> for (every record in table "instances")
>    for (every record in table "instance_fields")
> 

It does a nested loop.  There is no optimization for when the
same table is joined multiple times.  How often does that happy,
really?
--
D. Richard Hipp   <[EMAIL PROTECTED]>

Reply via email to