Re: [SQL] Comparing two slices within one table efficiently

2007-08-13 Thread Ken Simpson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Christian Kindler [13/08/07 21:34 +0200]: > Yes and you could make it even more speedy with the use table partitioning. > http://www.postgresql.org/docs/8.1/interactive/ddl-partitioning.html Thanks for all your speedy help, everyone. I tried doing a "

Re: [SQL] Comparing two slices within one table efficiently

2007-08-13 Thread Tom Lane
"=?utf-8?B?S2VuIFNpbXBzb24=?=" <[EMAIL PROTECTED]> writes: > select * from t t1 where exists (select 1 from t t2 where > t2.mta_id=t1.mta_id and t2.domain_id=t1.domain_id and (t2.attribute1 > != t1.attribute1 or t2.attribute2 != t1.attribute2) > This query takes millenia... Yeah, because you're e

Re: [SQL] Comparing two slices within one table efficiently

2007-08-13 Thread Christian Kindler
Yes and you could make it even more speedy with the use table partitioning. http://www.postgresql.org/docs/8.1/interactive/ddl-partitioning.html > select > t1.domain_id as domain_id, > t1.mta_id as mta_id, > t1.run_id as run_id_1, > t1.attribute1 as attribute1_1, > t1.attribute

Re: [SQL] Comparing two slices within one table efficiently

2007-08-13 Thread Andrew Kroeger
Ken Simpson wrote: > I have a table with the following simplified form: > > create table t ( > run_id integer, > domain_id integer, > mta_id integer, > attribute1 integer, > attribute2 integer, > unique(run_id, domain_id, mta_id) > ); > > The table has about 1 million rows with run_id=1, an

Re: [SQL] Comparing two slices within one table efficiently

2007-08-13 Thread chester c young
> I have a table with the following simplified form: > > create table t ( > run_id integer, > domain_id integer, > mta_id integer, > attribute1 integer, > attribute2 integer, > unique(run_id, domain_id, mta_id) > ); > > The table has about 1 million rows with run_id=1, another 1 million >

[SQL] Comparing two slices within one table efficiently

2007-08-13 Thread Ken Simpson
I have a table with the following simplified form: create table t ( run_id integer, domain_id integer, mta_id integer, attribute1 integer, attribute2 integer, unique(run_id, domain_id, mta_id) ); The table has about 1 million rows with run_id=1, another 1 million rows with run_id=2, and so