X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 39EAACC3C3 for ; Tue, 15 Jul 2003 14:38:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 14753-02 for ; Tue, 15 Jul 2003 14:39:05 +0000 (GMT) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id 2DD47CC2D8 for ; Tue, 15 Jul 2003 11:38:40 -0300 (ADT) Received: (qmail 11223 invoked from network); 15 Jul 2003 14:39:09 -0000 Received: from biglumber.com (HELO localhost) (207.228.252.42) by 0 with SMTP; 15 Jul 2003 14:39:09 -0000 From: greg@turnstep.com To: pgsql-sql@postgresql.org Subject: Re: max length of sql select statement (long!) X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <1058187439.5983.2.camel@sam> Date: Tue, 15 Jul 2003 14:39:09 -0000 X-Mailer: JoyMail 1.37 Message-ID: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/171 X-Sequence-Number: 14285 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > ... I don't want to take GO:000006 into account (two parents in which > I am intested in). That menas, whenever I ask for children of two nodes, > I want a DISTINCT SET of children. To start with, you can avoid the Java and do this in SQL: SELECT child FROM gograph WHERE parent='GO:0000002' OR parent='GO:0000005' EXCEPT (SELECT child FROM gograph WHERE parent='GO:0000002' INTERSECT SELECT child FROM gograph WHERE parent='GO:0000005'); And yes, I would certainly start by normalizing things a little bit: CREATE SEQUENCE goid_seq; CREATE TABLE goID ( idname TEXT, id INTEGER NOT NULL DEFAULT nextval('goid_seq') ); INSERT INTO goid(idname) SELECT DISTINCT parent FROM gograph; INSERT INTO goid(idname) SELECT DISTINCT child FROM gograph WHERE NOT EXISTS (SELECT 1 FROM goID WHERE idname = child); CREATE TABLE gomap ( parent INTEGER, child INTEGER ); INSERT INTO gomap SELECT (SELECT id FROM goid WHERE idname=parent), (SELECT id FROM goid WHERE idname=child) FROM gograph As far as the binaryInteraction table, a little more information is needed: how are each of these tables being populated? Why the distinct? Is it because there may be duplicate rows in the table? The reason I as is that it might be better to ue triggers to compute some of the information as it comes in, depending on which tables are changes and how often. - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200307151035 -----BEGIN PGP SIGNATURE----- Comment: http://www.turnstep.com/pgp.html iD8DBQE/FBGrvJuQZxSWSsgRAlEfAKCL4ttDdTRHxPRW9N00nowPh1/q/QCgqrkv e7Ncj4al4aJ4ihktEyweJJo= =Z/rk -----END PGP SIGNATURE-----