From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
Cc: | John Lange <lists(at)darkcore(dot)net>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query plan and Inheritance. Weird behavior |
Date: | 2003-01-23 06:07:47 |
Message-ID: | 23641.1043302067@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
> On 22 Jan 2003, John Lange wrote:
>> In this way the parent table would not need to know, nor would it care
>> about child tables in any way (just like inheritance in most programming
>> languages). If done this way a select on a parent table would only
>> require the retrieval of a single row and a select on a child table
>> would only require the retrieval of two rows (one in the child table and
>> one in the parent table).
No, it'd require the retrieval of N rows: you're failing to think about
multiple levels of inheritance or multi-parent inheritance, both of
which are supported reasonably effectively by the current model.
My guess is that this scheme would crash and burn just on locking
considerations. (When you want to update a child row, what locks do you
have to get in what order? With pieces of the row scattered through
many tables, it'd be pretty messy.)
You may care to look in the pghackers archives for prior discussions.
The variant scheme that's sounded most interesting to me so far is to
store *all* rows of an inheritance hierarchy in a single physical table.
This'd require giving up multiple inheritance, but few people seem to
use that, and the other benefits (like being able to enforce uniqueness
constraints over the whole hierarchy with just a standard unique index)
seem worth it. No one's stepped up to bat to do the legwork on the idea
yet, though. One bit that looks pretty tricky is ALTER TABLE ADD
COLUMN.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Timur Irmatov | 2003-01-23 08:14:25 | types & index usage |
Previous Message | Stephan Szabo | 2003-01-23 02:45:18 | Re: Query plan and Inheritance. Weird behavior |