Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: langsame "NOT IN" Subquery



Hallo Thomas,

Steubesand, Thomas <T(dot)Steubesand(at)rz(dot)fh-trier(dot)de> wrote:
> Es sollen ALLE Datensätze aus table1 herausgefunden werden,
> die KEINEN entsprechenden Datensatz in der table2 haben:

versuch mal:

SELECT table1.id, ...
    FROM table1
        LEFT OUTER JOIN table2
            ON table1.id = table2.t1_id
    WHERE table2.t1_id IS NULL
;

wenn es in t2.t1_id IDs mehrfach gibt, ist evt. schneller erst noch mal zu
deduplizieren, die tatsächlich gejointen Records werden aber eh wieder
verworfen...

Gruß
Tobias




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group