Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E96626328BC for ; Wed, 6 Jan 2010 19:54:09 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 83112-03 for ; Wed, 6 Jan 2010 23:53:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f192.google.com (mail-yx0-f192.google.com [209.85.210.192]) by mail.postgresql.org (Postfix) with ESMTP id 9869963275C for ; Wed, 6 Jan 2010 19:53:58 -0400 (AST) Received: by yxe30 with SMTP id 30so20005678yxe.29 for ; Wed, 06 Jan 2010 15:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=JViHBGW0n4lRjEDk1t5WnVqZ2rIoUwaFr17ZGyuXe34=; b=fh7VOA6a2m4gxEzpBo/ZvNjAD88cz5MWbv1QBHJ3sy2rQiNCLYtoVdtuFN06tMQT3A DQVgiM5xqnie9Zh2EL4x71U6iCVNJKKb9Y65GLMoSwuzHJcLSzP6CipWSqC+Qq4vNaGo dNsEnYXxLtkhPCRuVW/fiKOTkap5ri2pwqx+0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=Ez+DUpygoV9na6bTYxYaHF2iE1G50To5myTCZ6tWGIgY/A8hURWAXLK4eJG9vYR2vI 9uP+o9F+6K67OhM9G21Vm3wqrgblJ3vyyQ9NfjDQrzFN/4T+mHs2Ub3xbPsbK1x1JV2I OxZRnjUF4iDdWZskcbIqIGLTTPiJrRQ4m+URU= MIME-Version: 1.0 Received: by 10.150.19.30 with SMTP id 30mr6657620ybs.134.1262822036996; Wed, 06 Jan 2010 15:53:56 -0800 (PST) Date: Wed, 6 Jan 2010 18:53:56 -0500 X-Google-Sender-Auth: 333f6fbb5a4497ed Message-ID: <22f7878e1001061553j69b3b461hadd4633c58c5304f@mail.gmail.com> Subject: noob inheritance question From: Zintrigue To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=000e0cd6afe0ee011d047c87aa2d X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.19 tagged_above=-10 required=5 tests=BAYES_50=0.001, FH_DATE_PAST_20XX=3.188, HTML_MESSAGE=0.001 X-Spam-Level: *** X-Archive-Number: 201001/65 X-Sequence-Number: 36945 --000e0cd6afe0ee011d047c87aa2d Content-Type: text/plain; charset=UTF-8 Hello, I am complete noob to Postgres and to this list, and I hope this will be the appropriate list for this question. I'm hoping the inheritance feature will be a nice alternative method for me to implement categories in particular database of products I need to keep updated. I suppose in MySQL I would probably do this by creating, for example, one table for the products, and then a table(s) for categories, and then I'd be faced with a choice between using an adjacency list or nested set paradigm for, say, breadcrumb links in my private web app. On the other hand, in Postgres what I'd like to do it just create an empty root "product" table, then create, for example, a "spirts" table that inherits from products, and "rums" table that inherits from spirits, and then "aged rum", "flavored rum", et al, which inherit from rums. In this scenario, my idea was to have all my fields in "products" and to not add any additional fields in the child tables. Also, only the lowest level of child tables in any given branch of products would actually contain data / rows. Assuming this is a good design, what I'm wondering is how inheritance is actually implemented deep down inside Postgres, if it's anything at all like JOINS (say, in the case of merely doing: SELECT * FROM "flavored_rum" (the lowest level in a given branch) or SELECT * FROM "spirits" (the root level, or some intermediate level in a given branch) I'm wondering if there's any performance penalty here, analogous to the penalty of JOINs in a regular RDBMS (versus an ORDBMS). If anyone can offer in any insight as too how inheritance is actually executed (compared to JOINs especially), I'd be most grateful. Thank you, DG --000e0cd6afe0ee011d047c87aa2d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello,

I am complete noob to Postgres and to this list, = and I hope this will be the appropriate list for this question.
<= br>
I'm hoping the inheritance feature will be a nice alterna= tive method for me to implement categories in particular database of produc= ts I need to keep updated. I suppose in MySQL I would probably do this by c= reating, for example, one table for the products, and then a table(s) for c= ategories, and then I'd be faced with a choice between using an adjacen= cy list or nested set paradigm for, say, breadcrumb links in my private web= app.

On the other hand, in Postgres what I'd like to do = it just create an empty root "product" table, then create, for ex= ample, a "spirts" table that inherits from products, and "ru= ms" table that inherits from spirits, and then "aged rum", &= quot;flavored rum", et al, which inherit from rums.

In this scenario, my idea was to have all my fields in = "products" and to not add any additional fields in the child tabl= es. Also, only the lowest level of child tables in any given branch of prod= ucts would actually contain data / rows.

Assuming this is a good design, what I'm wondering = is how inheritance is actually implemented deep down inside Postgres, if it= 's anything at all like JOINS (say, in the case of merely doing:
SELECT * FROM "flavored_rum" (the lowest level in a given br= anch)
or
SELECT * FROM "spirits" (the root le= vel, or some intermediate level in a given branch)

I'm wondering if there's any performance penalty here, analogo= us to the penalty of JOINs in a regular RDBMS (versus an ORDBMS).

If anyone can offer in any insight as too how inheritance i= s actually executed (compared to JOINs especially), I'd be most gratefu= l.

Thank you,
DG

--000e0cd6afe0ee011d047c87aa2d--