Define recursive composite types Is it possible to define recursive composite types in Postgres 13?
create type &quot;t&quot; as (
  &quot;a&quot; int,
  &quot;b&quot; t
);

I am aware that I can use a table with a parent-child relationship. The only disadvantage is that I will need to query each nested level instead of directly accessing the nested data.
I am also aware that I can use jsonb, but I am not sure if it can access the nested data directly without querying each nested level?
What are the other alternatives using PL/pgSQL only?
I need to access each nested level separately.
No, &quot;recursive&quot; type definitions are not possible in Postgres.
You cannot reference a type in CREATE TYPE that is not registered, yet.
(What would terminate the recursion anyway?)