Re: Idea: Avoid JOINs by using path expressions to follow FKs
Joel Jacobson <joel@compiler.org>
From: "Joel Jacobson" <joel@compiler.org>
To: pgsql-hackers@lists.postgresql.org
Date: 2021-04-06T08:11:03Z
Lists: pgsql-hackers
In a Hacker News discussion [2] on using foreign keys for joins, the author of PostgREST, Steve Chavez, mentioned they are actually already using this idea in PostgREST: Steve Chavez wrote: >The idea about using FK as a JOIN target is interesting. >While developing a syntax for PostgREST resource embedding[1], >I also reached the conclusion that FKs would be a convenient way to join tables >(also suggested renaming them as you do here). > >IIRC, self joins are still an issue with FK joining. > >[1]: https://postgrest.org/en/v7.0.0/api.html#embedding-disambiguation I think this idea looks very promising and fruitful. Maybe we can think of some other existing/new operator which would be acceptable, instead of using "->" (which is potentially in conflict with the SQL standard's "REF" thing)? Not saying we should move forward on our own with this idea, but if we can come up with a complete proposal, maybe it can be presented as an idea to the SQL committee? [2] https://news.ycombinator.com/item?id=26693705 /Joel
Commits
-
Clean up generation of default names for constraints, indexes, and serial
- 45616f5bbbb8 8.0.0 cited