【发布时间】:2023-03-19 06:04:01
【问题描述】:
我正在使用带有 ColdFusion 2016 的 Azure 中的数据库。我正在使用 Sqljdbc41.jar from(有关如何配置它的有用链接:link1link2)这是我的查询。 [uuid] 上面有一个索引,是 varchar(36),pkIdentity 是一个主键 int。
select pkIdentity
from tbl1
where [uuid] = <cfqueryparam cfsqltype="cf_sql_varchar" value="#attributes.uuid#" maxlength="36">
此查询在 Azure 中消耗最多的 DTU。 Coldfusion 以
的形式将其发送到 Azure(@P0 nvarchar(4000))select pkIdentity
from tbl1
where [uuid]= @P0
我了解到,将 jdbc 驱动程序上的设置传递给 Azure SQL 时可能是 casting the varchar datatype as varchar。但是,我没有在 CF 数据库设置屏幕中禁用转换为 nvarchar 的选项。
我认为这些是我的选择。你觉得哪个更好?
- 当你使用coldfusion时,尝试逆向工程 cfqueryparam 但指定正确的数据类型(使用 sp_prepexec ?)
- 完全删除使用 cfqueryparam 在将字符串硬编码到查询中之前验证该字符串是有效的 uuid (例如 where [uuid] = '#attributes.uuid#'),但我担心我会失去对 Azure SQL Performance Insight 工具中此查询的所有执行的可见性
【问题讨论】:
-
您如何确定您关于 ColdFusion 如何发送参数的声明?
-
您认为转换为 nvarchar 会减慢查询速度吗? jochenhebbrecht.be/site/2014-05-01/java/…
jdbc:sqlserver://localhost\SQLEXPRESS;DatabaseName=TESTDB;sendStringParametersAsUnicode=false -
如果问题出在某个设置上,我建议您更努力地更改该设置。
-
倾向于@DanBracuk 的回复,我也会放弃您正在使用的 SQL JDBC jar,转而使用 CF2016 附带的本机 SQL Server 驱动程序。在过去的 8 年里,我以前的雇主从 CF 8 到 9 到 2016 年。在转换为 CF 9 时,我们移除了该 JAR 文件。不得不进行一些代码更改以说明当时处理一些事情的方式,但出于性能和稳定性的原因,我们需要进行更改。跨度>
标签: sql-server jdbc coldfusion azure-sql-database coldfusion-2016