Re: [sqlite] self joins efficiency question

2006-02-03 Thread Marvin K. Bellamy
Kurt Welgehausen wrote: select user_id from person p1, person p2 where p1.user_id<>p2.user_id and p1.name = p2.name Your query is fine. It's slow because it's doing a full scan of p1, and for each row in p1 it's doing a full scan of p2. That makes the time O(n^2). It should go much

Re: [sqlite] self joins efficiency question

2006-02-02 Thread Kurt Welgehausen
> select user_id from person p1, person p2 where p1.user_id<>p2.user_id > and p1.name = p2.name Your query is fine. It's slow because it's doing a full scan of p1, and for each row in p1 it's doing a full scan of p2. That makes the time O(n^2). It should go much faster if you add an index on

Re: [sqlite] self joins efficiency question

2006-02-02 Thread Paolo Vernazza
Marvin K. Bellamy ha scritto: I'm still a noob to SQL and I *think* I just found my first real-world need to perform a self join. Given the table: person (user_id integer primary key, name text) I want to find all the entries with identical names (before adding a unique index). I executed

Re: [sqlite] self joins efficiency question

2006-02-02 Thread Jay Sprenkle
On 2/2/06, Marvin K. Bellamy <[EMAIL PROTECTED]> wrote: > I'm still a noob to SQL and I *think* I just found my first real-world > need to perform a self join. Given the table: > > person (user_id integer primary key, name text) > > I want to find all the entries with identical names (before

[sqlite] self joins efficiency question

2006-02-02 Thread Marvin K. Bellamy
I'm still a noob to SQL and I *think* I just found my first real-world need to perform a self join. Given the table: person (user_id integer primary key, name text) I want to find all the entries with identical names (before adding a unique index). I executed this query which took an