SQL 中的后处理与代码中的后处理

发布于 2024-08-05 18:05:34 字数 188 浏览 4 评论 0原文

我有一个与处理查询中的行相关的一般查询。一般来说,我总是尝试在 SQL 本身中格式化/处理我的行,使用大量 CASE WHEN 语句来预先格式化我的数据库结果,限制行并根据其他列填充列。

但是,您也可以选择只选择所有行并在代码中进行后处理(在我的例子中是 asp.NET)。你们认为就性能而言最好的方法是什么?

提前致谢, 斯泰因

I have a general inquiry related to processing rows from a query. In general, I always try to format/process my rows in SQL itself, using numerous CASE WHEN statements to pre-format my db result, limiting rows and filling columns based on other columns.

However, you can also opt to just select all your rows and do the post-processing in code (asp.NET in my case). What do you guys think is the best approach in terms of performance?

Thanks in advance,
Stijn

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好多鱼好多余 2024-08-12 18:05:34

我建议在代码中进行处理,除非您有网络带宽考虑。原因很简单,更改代码通常比更改数据库更容易。此外,性能通常与实际的数据库查询和磁盘访问有关,而不是与返回的数据量有关。

但是,我假设您指的是对结果进行“微小”格式更改。标准的where子句自然应该在数据库中完成。

I would recommend doing the processing in the code, unless you have network bandwidth considerations. The simple reason for this is that is is generally easier to make code changes than database changes. Furthermore, performance is more often related to the actual database query and disk access rather than the amount of data returned.

However, I'm assuming that your are referring to "minor" formatting changes to the result. Standard where clauses should naturally be done in the database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文