From: | Achilleas Mantzios - cloud <a(dot)mantzios(at)cloud(dot)gatewaynet(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | PostgreSQL inheritance vs https://wiki.postgresql.org/wiki/Don%27t_Do_This |
Date: | 2023-10-23 11:45:22 |
Message-ID: | 2f106761-daa8-6b26-013e-884da25322c2@cloud.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello All
in the wiki above and specifically in this commit :
https://wiki.postgresql.org/index.php?title=Don%27t_Do_This&type=revision&diff=33210&oldid=33082
someone added this section about inheritance :
"
Don't use table inheritance
Don't use table inheritance
<https://www.postgresql.org/docs/current/tutorial-inheritance.html>. If
you think you want to, use foreign keys instead.
Why not?
Table inheritance was a part of a fad wherein the database was closely
coupled to object-oriented code. It turned out that coupling things that
closely didn't actually produce the desired results.
When should you?
Never …almost. Now that table partitioning is done natively, that common
use case for table inheritance has been replaced by a native feature
that handles tuple routing, etc., without bespoke code.
One of the very few exceptions would be temporal_tables
<https://github.com/arkhipov/temporal_tables> extension if you are in a
pinch and want to use that for row versioning in place of a lacking SQL
2011 support. Table inheritance will provide a small shortcut instead of
using |UNION ALL| to get both historical as well as current rows. Even
then you ought to be wary of caveats
<http://clarkdave.net/2015/02/historical-records-with-postgresql-and-temporal-tables-and-sql-2011/#using-inheritance>
while working with parent table.
"
I believe this text is false on too many accounts. So, what's the
consensus about Inheritance in PostgreSQL, I am going to give a talk on
it in November and I wouldn't like to advertise/promote/teach something
that the community has decided to abandon or drop. Actually I proposed
several topics and they chose this one (Inheritance).
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2023-10-23 14:01:56 | Re: PostgreSQL inheritance vs https://wiki.postgresql.org/wiki/Don%27t_Do_This |
Previous Message | Achilleas Mantzios - cloud | 2023-10-23 10:38:16 | Re: Presentation tools used ? |