Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1EJbdE54720 for ; Thu, 14 Feb 2002 14:37:39 -0500 (EST) (envelope-from oleg@sai.msu.su) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.9.3/8.9.3) with ESMTP id WAA19491; Thu, 14 Feb 2002 22:37:30 +0300 (GMT) Date: Thu, 14 Feb 2002 22:37:29 +0300 (GMT) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: Christian Brink cc: pgsql-sql@postgresql.org Subject: Re: Is this the most efficent way to child nodes off a N-ary In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200202/159 X-Sequence-Number: 6585 Christian, take a look at our contrib/tree module, available from http://www.sai.msu.su/~megera/postgres/gist/ Oleg On Thu, 14 Feb 2002, Christian Brink wrote: > I have created this SQL statment, used to pull the child/leaf nodes off of a > N-ary node structure in PostgreSQL. > > Is my premise all wrong? > > Is this efficent as a SQL select? > > Should this be done in my code (something I try to avoid for abstraction > reasons)? > > "SELECT DISTINCT t1.node_id FROM node t1 WHERE NOT EXISTS (SELECT > t1.node_id FROM node t2 WHERE t1.node_id = t2.parent_id);" > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83