Re: Idea: Avoid JOINs by using path expressions to follow FKs

Joel Jacobson <joel@compiler.org>

From: "Joel Jacobson" <joel@compiler.org>
To: "Vik Fearing" <vik@postgresfriends.org>, "Tom Lane" <tgl@sss.pgh.pa.us>, "Andrew Dunstan" <andrew@dunslane.net>
Cc: "Alvaro Herrera" <alvherre@alvh.no-ip.org>, pgsql-hackers@lists.postgresql.org
Date: 2021-03-29T15:50:20Z
Lists: pgsql-hackers
On Mon, Mar 29, 2021, at 16:17, Vik Fearing wrote:
> If you write your schema like this, then it becomes standards compliant:
> ...
> CREATE TABLE order_details (
>     "order" REF(orders),
>     product REF(products),
>     quantity integer,
>     PRIMARY KEY ("order", product)
> );
> 
> 
> And the query would be:
> 
> SELECT DISTINCT order_details."order"->customer->company_name
> FROM order_details
> WHERE order_details.product->product_name = 'Chocolade';
> 
> 
> Postgres already supports most of that, but not all of it.

Thanks for making me aware of this.
I can see this is "4.9 Reference types" in ISO/IEC 9075-2:2016(E).

This looks awesome.

/Joel

Commits

  1. Clean up generation of default names for constraints, indexes, and serial