3 ms·
I think what paddy_m complains about is SQL’s tendency to require copy-paste programming. For example, a phrase like row-number() over (partition by grp order
by Someone 8y ago
I think what paddy_m complains about is SQL’s tendency to require copy-paste programming.
For example, a phrase like row-number() over (partition by grp order by id) might return in many, many of your stored procedures, but there’s no way to only write it once in SQL.
The same thing effectively applies to that common table expression. There, you can create a view, and just write
select grp, id from grouped_tests where rn = 1;
, but many SQL query planners won’t optimize queries that well across views, so you end up copy-pasting the CTE, or, worse, not even doing that because you have to write an even uglier query to get decent performance.