-- -- a is the type root -- b and c inherit from a (one-level single inheritance) -- d inherits from b and c (two-level multiple inheritance) -- e inherits from c (two-level single inheritance) -- f inherits from e (three-level single inheritance) -- CREATETABLE a_star (
class char,
a int4
);
CREATETABLE b_star (
b text
) INHERITS (a_star);
CREATETABLE c_star (
c name
) INHERITS (a_star);
CREATETABLE d_star (
d float8
) INHERITS (b_star, c_star);
CREATETABLE e_star (
e int2
) INHERITS (c_star);
CREATETABLE f_star (
f polygon
) INHERITS (e_star);
INSERTINTO a_star (class, a) VALUES ('a', 1);
INSERTINTO a_star (class, a) VALUES ('a', 2);
INSERTINTO a_star (class) VALUES ('a');
INSERTINTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text);
INSERTINTO b_star (class, a) VALUES ('b', 4);
INSERTINTO b_star (class, b) VALUES ('b', 'bumble'::text);
INSERTINTO b_star (class) VALUES ('b');
INSERTINTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::name);
INSERTINTO c_star (class, a) VALUES ('c', 6);
INSERTINTO c_star (class, c) VALUES ('c', 'hi paul'::name);
-- Analyze the X_star tables for better plan stability in later tests ANALYZE a_star; ANALYZE b_star; ANALYZE c_star; ANALYZE d_star; ANALYZE e_star; ANALYZE f_star;
-- -- inheritance stress test -- SELECT * FROM a_star*;
SELECT * FROM b_star* x WHERE x.b = text 'bumble'or x.a < 3;
SELECT class, a FROM c_star* x WHERE x.c ~ text 'hi';
SELECT class, b, c FROM d_star* x WHERE x.a < 100;
SELECT class, c FROM e_star* x WHERE x.c NOTNULL;
SELECT * FROM f_star* x WHERE x.c ISNULL;
-- grouping and aggregation on inherited sets have been busted in the past...
SELECT sum(a) FROM a_star*;
SELECT class, sum(a) FROM a_star* GROUPBY class ORDERBY class;
ALTERTABLE f_star RENAMECOLUMN f TO ff;
ALTERTABLE e_star* RENAMECOLUMN e TO ee;
ALTERTABLE d_star* RENAMECOLUMN d TO dd;
ALTERTABLE c_star* RENAMECOLUMN c TO cc;
ALTERTABLE b_star* RENAMECOLUMN b TO bb;
ALTERTABLE a_star* RENAMECOLUMN a TO aa;
SELECT class, aa FROM a_star* x WHERE aa ISNULL;
-- As of Postgres 7.1, ALTER implicitly recurses, -- so this should be same as ALTER a_star*
ALTERTABLE a_star RENAMECOLUMN aa TO foo;
SELECT class, foo FROM a_star* x WHERE x.foo >= 2;
ALTERTABLE a_star RENAMECOLUMN foo TO aa;
SELECT * from a_star* WHERE aa < 1000;
ALTERTABLE f_star ADDCOLUMN f int4;
UPDATE f_star SET f = 10;
ALTERTABLE e_star* ADDCOLUMN e int4;
--UPDATE e_star* SET e = 42;
SELECT * FROM e_star*;
ALTERTABLE a_star* ADDCOLUMN a text;
-- That ALTER TABLE should have added TOAST tables. SELECT relname, reltoastrelid <> 0AS has_toast_table FROM pg_class WHERE oid::regclass IN ('a_star', 'c_star') ORDERBY1;
--UPDATE b_star* -- SET a = text 'gazpacho' -- WHERE aa > 4;
SELECT class, aa, a FROM a_star*;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.