- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在运行 MySQL 5.6.33,并且有一个更新查询运行得相当慢,我不明白为什么。
我有两个表:alltranscur有35908行,acctnumcust有86103行。
查询:
update alltranscur a inner join acctnumcust d
on a.acctNumber=d.acctNum
set
a.custID=d.custID
需要很长时间(5 分 58.29 秒,匹配约 22,000 行)。我也可以将其写为:
update alltranscur a, acctnumcust d
set
a.custID=d.custID
where a.acctNumber=d.acctNum
同样的结果。
建表语句是:
CREATE TABLE `alltranscur` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`custID` varchar(200) DEFAULT NULL,
`acctNumber` int(11) DEFAULT NULL,
... other columns
PRIMARY KEY (`id`),
KEY `acctNumber` (`acctNumber`),
... other keys
CONSTRAINT `alltranscur_ibfk_8` FOREIGN KEY (`custID`) REFERENCES `custdata` (`custID`) ON UPDATE CASCADE
... other foreign keys
) ENGINE=InnoDB AUTO_INCREMENT=5226303 DEFAULT CHARSET=latin1
和
CREATE TABLE `acctnumcust` (
`acctnum` varchar(50) NOT NULL,
`custid` varchar(200) NOT NULL,
PRIMARY KEY (`acctnum`),
KEY `custid` (`custid`),
KEY `acctnum` (`acctnum`,`custid`),
CONSTRAINT `acctnumcust_ibfk_1` FOREIGN KEY (`custid`) REFERENCES `custdata` (`custID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
如果我
explain
update alltranscur a inner join acctnumcust d
on a.acctNumber=d.acctNum
set
a.custID=d.custID
我得到:
+----+-------------+-------+-------+-----------------+------------+---------+---------------+-------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+-----------------+------------+---------+---------------+-------+-------------+
| 1 | SIMPLE | d | index | PRIMARY,acctnum | custid | 202 | NULL | 85152 | Using index |
| 1 | SIMPLE | a | ref | acctNumber | acctNumber | 5 | pcb.d.acctnum | 1 | Using where |
+----+-------------+-------+-------+-----------------+------------+---------+---------------+-------+-------------+
我原以为 MySQL 会在 acctnum 上使用 PRIMARY 键,或者甚至可能在 acctnum/custID 上使用组合键。但事实并非如此。
这和这样的查询一样快吗?过去,我已经加入了类似大小的表的更新,但他们并没有花费那么长的时间。我是否遗漏了这些表格的某些内容?有没有办法让它运行得更快?
最佳答案
问题的根本原因很可能是您将 2 个表连接到具有不同数据类型的列上
`acctNumber` int(11) DEFAULT NULL,
`acctnum` varchar(50) NOT NULL,
where a.acctNumber=d.acctNum
这意味着 MySQL 不能直接使用索引并以全表扫描结束。
将 acctnumcust
表中 acctnum
列的数据类型更改为 INT(11),您的性能问题应该得到解决
关于MySQL加入更新运行缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51193796/
我最近从 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
我是一名优秀的程序员,十分优秀!