"Never do in code what you can get the SQL server to do well for you" - Is this a recipe for a bad design?
Posted
by
PhonicUK
on Programmers
See other posts from Programmers
or by PhonicUK
Published on 2012-10-23T15:32:00Z
Indexed on
2012/10/23
17:19 UTC
Read the original article
Hit count: 165
design-patterns
|sql
It's an idea I've heard repeated in a handful of places. Some more or less acknowledging that once trying to solve a problem purely in SQL exceeds a certain level of complexity you should indeed be handling it in code.
The logic behind the idea is that for the large majority of cases, the database engine will do a better job at finding the most efficient way of completing your task than you could in code. Especially when it comes to things like making the results conditional on operations performed on the data. Arguably with modern engines effectively JIT'ing + caching the compiled version of your query it'd make sense on the surface.
The question is whether or not leveraging your database engine in this way is inherently bad design practice (and why). The lines become blurred further when all the logic exists inside the database and you're just hitting it via an ORM.
© Programmers or respective owner