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
> 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
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
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
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
5 matches
Mail list logo