CF - 环比与查询 [英] CF - QoQ vs Query

查看:9
本文介绍了CF - 环比与查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个概念,即调用查询查询比从数据库查询更快,因为减速是在 cf 和 db 之间的通信.这是真的吗.

这是否意味着循环内的 QoQ 是可接受的,而循环内的查询则不是.

解决方案

完整的 DBMS 针对处理 [适当编写的] 查询进行了高度优化,在现代网络上开销不会很大.

QoQ 是使用嵌入式数据库执行的,根据执行的查询类型,该数据库可能优化也可能不好.

因此,如果数据库位于另一台机器上,并且网络速度较慢,那么在某些情况下,QoQ 可能会不那么慢.如果您要访问数据库,理想情况下,您希望在一个请求中正确处理所有内容,并避免循环中的往返和重新处理.

当然,QoQ 的一大好处是您可以使用它来处理并非来自数据库的数据,例如 cfdirectory 的结果或已转换为查询的 CSV 文件.


ColdFusion 通过手动解析 SQL 然后循环遍历记录集来执行 QoQ.这使得它对于简单的操作很有效,例如具有匹配键的两表连接,但对于复杂组合(连接使用多个列和/或不是直接的 a=b 比较)效率较低.(简要信息)./p>

Railo 使用 H2.H2 声称速度很快,他们的网站提供了一些 速度比较,表明它比 Derby 和MySQL - 但当然最好寻找独立的第三方测试,更不用说这些测试不能保证 QoQ 性能(例如,我怀疑不会有索引).


一般来说:在没有先进行性能测试之前不要做出任何艰难的决定,以确定您确实需要提高性能,并能够客观地确定哪种方法实际上更快.

I've got a notion that calling a query of queries is faster than a query from database, because the slowdown is in the communication between cf and the db. Is this true.

Does that mean that a QoQ within a loop is acceptable, whereas a query within a loop is not.

解决方案

Full DBMS are highly optimised for processing [appropriately-written] queries, and on a modern network the overhead is not going to be huge.

QoQ are performed using an embedded database, which may or not be well optimised, depending on the type of query being performed.

So, if the database is on a different machine, across a slow network, the QoQ might be less slow in some situations. If you're hitting the database at all, you ideally want to get everything processed appropriately there, in one request, and avoid both round-trips and re-processing in a loop.

Of course, a big benefit of QoQ is that you can use it to process data that doesn't come from a database - such as the results of cfdirectory or a CSV file that has been converted to a query.


ColdFusion performs QoQ by manually parsing the SQL and then looping through the recordset. This makes it efficient for simple operations, such as a two-table join with matching keys, but less efficient for complex combinations (where joining uses multiple columns and/or is not a straight a=b comparison). (Brief info here.)

Railo uses H2. H2 claims to be fast, and their website offers some speed comparisons that suggest it is faster than Derby and MySQL - but of course it would be best to look for independent third-party tests, not to mention that these tests are not guarantees of QoQ performance (which I suspect wont have indexes, for example).


In general: don't make any hard decision without first doing performance testing to determine that you actually need to improve performance, and to be able to objectively determine which method is actually faster.

这篇关于CF - 环比与查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆