Re:Show HN: JinjaSQL – Generate SQL Queries using a Jinja Te...
by tkyjonathan on Friday November 04, 2016 @05:26AM
(#12871273)
This is good. SQL templates are usually much faster for database queries than using ORMs.
[ Parent
| on HN ]
Re:Show HN: JinjaSQL – Generate SQL Queries using a Jinja Te...
by nathancahill on Friday November 04, 2016 @08:22AM
(#12871984)
I'll take the bait. It's easy to write a slow SQL query, and equally easy to write a fast ORM query. In the long run, for readability and maintainability, ORMs win most of the time. I've rarely found a slow ORM query that couldn't be fixed without resorting to SQL (half the time it's bad indexes, half the time it's doing something un-performant in the ORM).
The few times when I do need to force a certain SQL syntax that the ORM won't give me, I drop down to SQL. But doing that doesn't magically make all queries faster.
Re:Show HN: JinjaSQL – Generate SQL Queries using a Jinja Te...
by traviscj on Friday November 04, 2016 @08:54AM
(#12872151)
My favorite trick is binding a hook in unit test modules that basically runs an "explain q" for every query "q", and asserts that it found an appropriate index to use. Then as long as your unit tests exercise all queries your app needs, you know that your database indices are appropriate for your app's usages.
Re:Show HN: JinjaSQL – Generate SQL Queries using a Jinja Te...
by Can_Not on Friday November 04, 2016 @08:28PM
(#12877383)
I wish laravel had this and an automated SQL debug comment feature.
Re:Show HN: JinjaSQL – Generate SQL Queries using a Jinja Te...
by svisser on Friday November 04, 2016 @11:32AM
(#12873357)
> In the long run, for readability and maintainability, ORMs win most of the time.
It depends. Anyone working on that code now needs to learn the ORM, the SQL and how to let the ORM generate that SQL for anything beyond the basics.