4 ms·
> We have a few ~200 line long queries in one of our applications. With comments one of them is 460 lines. You can decompose large queries into smaller views/t
by riku_iki 8y ago
> We have a few ~200 line long queries in one of our applications. With comments one of them is 460 lines.
You can decompose large queries into smaller views/temp tables, and such queries will be much more readable..
- munk-a 8y agoIt depends how reused those subcomponents are, sometimes separating portions of the logic into views can obscure what's going on and end up increasing the LoC you need to parse to grok where a bug may be. It's a trade off.
- btilly 8y agoWith most databases, you don't need to reuse it to get the maintainability win with temporary tables. (The notable negative exception being Oracle.) Furthermore it gives you power to control the query plan - a feature that I've found very helpful with both MySQL and PostgreSQL on occasion.