Received: from jupiter.hub.org (jupiter.hub.org [64.49.215.5]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1EJOBE52432 for ; Thu, 14 Feb 2002 14:24:11 -0500 (EST) (envelope-from news@jupiter.hub.org) Received: (from news@localhost) by jupiter.hub.org (8.11.6/8.11.6) id g1EIu4I63917 for pgsql-sql@postgresql.org; Thu, 14 Feb 2002 12:56:04 -0600 (CST) (envelope-from news) From: "Christian Brink" X-Newsgroups: comp.databases.postgresql.sql Subject: Is this the most efficent way to child nodes off a N-ary node database? Date: Thu, 14 Feb 2002 10:52:47 -0800 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 15 Message-ID: X-Complaints-To: news@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: pgsql-sql@postgresql.org X-Archive-Number: 200202/156 X-Sequence-Number: 6583 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);"