| From: | "rob" <rob(at)cabrion(dot)com> |
|---|---|
| To: | "Diehl, Jeffrey" <jdiehl(at)sandia(dot)gov>, <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Help with query. (*) |
| Date: | 2001-01-19 04:37:40 |
| Message-ID: | 002201c081d1$8f402eb0$4100fd0a@cabrion.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-sql |
Read the docs on "exists" that should be what you are looking for.
--rob
----- Original Message -----
From: "Diehl, Jeffrey" <jdiehl(at)sandia(dot)gov>
To: <pgsql-sql(at)postgresql(dot)org>; <pgsql-general(at)postgresql(dot)org>
Cc: "Diehl, Jeffrey" <jdiehl(at)sandia(dot)gov>
Sent: Tuesday, January 16, 2001 3:42 PM
Subject: Help with query. (*)
> I'm having difficulty writing a query which I really can't live without...
>
> I need to get a list of records from table A for which there are
> corresponding records in table B. I've tried to use the intersect clause,
> but it doesn't seem to work, or it runs far too long. For example:
>
> select * from A
> where 1=1
> intersect select * from A where
> B.x=A.x
> and A.y=B.y
> and A.z=B.z
> limit 100
>
> I need the most efficient method possible; my A tables have upward of 5
> Million records. The B table, btw, only has about 100 records.
>
>
> Any help will be most appreciated.
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2001-01-19 04:38:38 | Re: Performance of a single (big) select and Multiprocessor Machines |
| Previous Message | Barry Lind | 2001-01-19 04:34:19 | Problems building 7.1beta3 on WinNT under cygwin |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jussi Vainionpää | 2001-01-19 07:34:50 | Trouble with subqueries |
| Previous Message | Poet/Joshua Drake | 2001-01-19 00:59:22 | Re: PostgreSQL HOWTO |