Re: [R] sqldf: issues with natural joins

2010-05-20 Thread Gabor Grothendieck
They work on any join that is able to make use of them. If you preface the select statement with explain query plan then it will give you some info, e.g. > sqldf('explain query plan select * from main.A natural join main.B') order from detail 1 00 TABLE

Re: [R] sqldf: issues with natural joins

2010-05-20 Thread Nick Switanek
Thank you very much for these clarifying responses, Gabor. I had mistakenly assumed that creating the index on Tid restricted the natural join to joining on Tid. Can you describe when and how indices speed up joins, or can you point me to resources that address this? Is it only for natural joins o

Re: [R] sqldf: issues with natural joins

2010-05-20 Thread Gabor Grothendieck
Although that works I had meant to write: > names(B)[2] <- "dfNameB" > # ... other commands > sqldf('select * from main.A natural join main.B') so that now only Tid is in common so the natural join just picks it up and also the heuristic works again since we no longer retrieve duplicate column na

Re: [R] sqldf: issues with natural joins

2010-05-20 Thread Gabor Grothendieck
There are two problems: 1. A natural join will join all columns with the same names in the two tables and that includes not only Tid but also dfName and since there are no rows that have the same Tid and dfName the result has zero rows. 2. the heuristic it uses fails when you retrieve the same co