News for hackers. Stuff that matters.
Re:Better SQL JOINs by shazzdeeds on Saturday December 25, 2021 @06:45PM (#29688174)
This is effectively what CTE style syntax gives you. I always find them more intuitive for intermediate to advanced queries for exactly this reason. They’re also much easier for another reader to later come in and deduce what the query is doing.
Re:Better SQL JOINs by jansommer on Saturday December 25, 2021 @09:25PM (#29689107)
CTE's are indeed nice, but can also make your queries substantially slower, at least in Postgres
Re:Better SQL JOINs by DangitBobby on Sunday December 26, 2021 @03:23AM (#29690686)
That's mainly true because you don't have the benefit of an index when you join on a CTE, isn't it?
Re:Better SQL JOINs by jansommer on Sunday December 26, 2021 @03:06PM (#29695821)
It'a slow even without indexes. In other cases, where the CTE is used multiple times in the same query, it can be faster