- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 java 程序,它对 sql server 数据库运行一堆查询。其中第一个针对 View 的查询返回大约 750k 条记录。我可以通过 sql server management studio 运行查询,并在大约 30 秒内得到结果。但是,我昨晚启动了要运行的程序。今天早上我检查它时,大约 15 小时后,这个查询仍然没有将结果返回给 java 程序。
我可以访问数据库以执行任何我想做的事情,但我真的不确定如何开始调试它。应该怎么做才能弄清楚是什么导致了这种情况?我不是 dba,也不熟悉 sql server 工具集,因此如果您能提供更多有关如何执行您可能建议的操作的详细信息,我们将不胜感激。
代码如下
stmt = connection.createStatement();
clientFeedRS = stmt.executeQuery(StringBuffer.toString());
编辑1:
好吧,已经有一段时间了,这被搁置了,但这个问题又回来了。我研究了从 jdbc 驱动程序 v 1.2 升级到 2.0,但我们停留在 jdk 1.4 上,而 v 2.0 需要 jdk 1.5,所以这是一个非启动器。现在我正在查看我的连接字符串属性。我看到 2 可能有用。
SelectMethod=cursor|direct
responseBuffering=adaptive|full
目前,由于存在延迟问题,我使用游标作为 selectMethod 运行,并使用已满的 responseBuffering 默认值。改变这些属性可能有帮助吗?如果是这样,理想的设置是什么?根据我在网上可以找到的内容,我在想,使用直接选择方法和自适应响应缓冲可能会解决我的问题。有什么想法吗?
编辑2:
好吧,我结束了更改这两个连接字符串参数,使用默认选择方法(直接)并将 responseBuffering 指定为自适应。这最终对我来说效果最好,并减轻了我所看到的延迟问题。感谢所有的帮助。
最佳答案
我遇到了类似的问题,在 Java 中使用 jdbc 连接时,一个非常简单的请求 (SELECT . FROM . WHERE = .) 最多需要 10 秒才能返回一行,而在 sqlshell 中只需要 0.01 秒。无论我使用的是官方 MS SQL 驱动程序还是 JTDS 驱动程序,问题都是一样的。
解决方案是在 jdbc url 中设置此属性:sendStringParametersAsUnicode=false
完整示例,如果您使用的是 MS SQL 官方驱动程序:jdbc:sqlserver://yourserver;instanceName=yourInstance;databaseName=yourDBName;sendStringParametersAsUnicode=false;
如果使用不同的 jdbc 驱动程序和有关问题的更多详细信息,请参见此处的说明:http://emransharif.blogspot.fr/2011/07/performance-issues-with-jdbc-drivers.html
SQL Server differentiates its data types that support Unicode from the ones that just support ASCII. For example, the character data types that support Unicode are nchar, nvarchar, longnvarchar where as their ASCII counter parts are char, varchar and longvarchar respectively. By default, all Microsoft’s JDBC drivers send the strings in Unicode format to the SQL Server, irrespective of whether the datatype of the corresponding column defined in the SQL Server supports Unicode or not. In the case where the data types of the columns support Unicode, everything is smooth. But, in cases where the data types of the columns do not support Unicode, serious performance issues arise especially during data fetches. SQL Server tries to convert non-unicode datatypes in the table to unicode datatypes before doing the comparison. Moreover, if an index exists on the non-unicode column, it will be ignored. This would ultimately lead to a whole table scan during data fetch, thereby slowing down the search queries drastically.
在我的例子中,我在搜索的表中有超过 3000 万条记录。应用该属性后,完成请求的持续时间从 10 多秒减少到大约 0.01 秒。
希望这会对某人有所帮助!
关于java - sql server查询从java运行缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/961078/
我最近从 Indigo“升级”到了 Luna(Oracle OEPE 安装)。请注意围绕“升级”一词的引用。 不幸的是,事情很慢。 我使用的项目是一个 Maven 多模块项目。构建工作区操作大约需要
如果我的 JavaScript 事件似乎都不是网页性能问题的原因,我该如何诊断网页性能问题? 我有一个使用jqGrid的网络应用程序。单击网格会导致 2-3 秒的卡住,然后发生任何事情(包括点击任何单
从 appengine 访问我的应用程序时,我经常收到以下错误。有人可以知道这是什么原因吗? 原因:com.google.apphosting.api.DeadlineExceededExceptio
出于某种原因,我的 curl 调用非常慢。这是我使用的代码。 $postData = "test" $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $
Stackdriver 测试我的网站启动速度慢 我们使用 cloudflare 作为我们的站点 CDN 提供商。我们使用 stackdriver 从外部测试站点可用性,我们将时间检查间隔设置为 1 分
在插入/更新许多行时,我知道SQLite的“问题”,但事实并非如此。 我正在更新包含约250条记录的表中的ONE一行(由PK索引)中的ONE字段。查询通常需要200毫秒左右的时间。听起来很少,但很大。
我们的 Mongo 数据库会定期(有时每天一次)变慢约 30-40 分钟。在此缓慢时期,访问数据库的 API 会遇到每 5-10 分钟就会出现一次的高延迟峰值。 查看 mongod 日志文件,这两
这个问题已经在这里有了答案: 已关闭8年。 Possible Duplicate: C# WinForm Application - UI Hangs during Long-Running Oper
我最近将我的 Java Liquibase 版本从 3.5.3 升级到 3.6.3 我有一个非常繁重的环境,其中有很多数据库和表(我使用的是 Oracle)。 在这种环境下,我试图执行一个巨大的变更日
在我的项目中,为了整洁起见,模块被组织在子目录中。 我的项目目录层次结构: $ ls -R .: configure.in Makefile.am Makefile.cvs src
我正在 Debian 上使用存储库中的软件包运行 Gitlab。大多数时候Gitlab运行速度非常快,但是在较长的空闲时间后Gitlab非常慢甚至超时(错误502)。有一次我在远程 git 访问上也遇
这可能是菜鸟的错误,所以请原谅我。我在高处和低处寻找解决方案,但没有结果-因此,我想在此添加第一篇文章:-) 我有两个域类,一个称为Domain,一个称为Page。如下代码所示,域中有许多页面。 cl
我是 React 的新手,在使用 onChange 时遇到了问题在大数据列表中生成的输入字段上的方法。 如 parentcomponent是数据的拥有者,我提供了handleUpdate()子组件 (
我们使用 Webpack DefinePlugin 为不同的渲染模式生成输出包。因此,例如,我们的 webpack 配置将返回 [{ entry: { mode1: "./in
我在页面顶部有一个带有菜单的标题元素。当我向下滚动时,标题会动画到较低的高度。当我向上滚动并到达顶部时,标题会以动画方式显示为原始大小。 但它的工作并不完美。有时,事情发生之前需要两秒钟。特别是当我向
我今天在我的文本编辑器(Sublime)中写了一些正则表达式,试图快速找到特定的源代码段,这需要有点创意,因为有时函数调用可能包含更多函数调用。例如,我正在寻找 jQuery 选择器: $("div[
ParentSadly 我没有通过搜索“laggy/slow mouse wheel-scrolling in Rich Edit control”和类似的句子找到答案。 我创建了一个丰富的编辑控件
我遇到了“OR”运算符在 mysql 中未使用任何索引的典型性能问题: SELECT sms.smsID, sms.phonenumber, sms.text, date, mbr.name, mbr
我最近一直在玩 asyncio 模块。下面是我想出的用于发送一些并行请求的代码,这些请求在我的笔记本电脑 (Mac OS) 上似乎运行良好,但在另一台机器 (Ubuntu 18.04) 上似乎运行缓慢
我目前正在开发一个并行应用程序(C#、WinForms),它通过 COM 将消息注入(inject)应用程序。 此应用程序使用多个 foreach 语句,从接受 COM 的应用程序中轮询实体指标。 L
我是一名优秀的程序员,十分优秀!