- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个表,其中包含用户的日常事件。我有两个加入这些表并从此表中选择前十个 ID。
表 1:构建日志
+----------------+------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------------+------+-----+---------+----------------+
| NAME | varchar(50) | YES | | NULL | |
| ID | int(11) | NO | PRI | NULL | auto_increment |
| DATE_AND_TIME | datetime | YES | | NULL | |
| COMMENT | mediumtext | YES | | NULL | |
+----------------+------------------------+------+-----+---------+----------------+
行数:276186
表 2:报告
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| r_id | int(10) | NO | PRI | NULL | auto_increment |
| id | int(15) | YES | UNI | NULL | |
| label | varchar(200) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
行数:134058
如果我仅对使用 id
的这两个表使用连接查询,它会非常快。
查询 1:
select buildlog.id,reports.label from buildlog join reports on reports.id = buildlog.id limit 10\G
查询时间:一组 10 行(0.01 秒)
如果我添加 order by 以获取最新的十个构建 ID,标记它需要 1 到 2 分钟才能执行。
查询 2:
select buildlog.id,reports.label from buildlog join reports on reports.id = buildlog.id order by buildlog.id desc limit 10\G
查询时间:集合中有 10 行(0.98 秒)
按列排序是一个主键 buildlog.id
。那么,它已经编入索引为什么执行此查询需要更多时间? .谁能建议我如何优化它?
最佳答案
SELECT * FROM (
SELECT
buildlog.id,
reports.label
FROM
buildlog
JOIN
reports
ON
reports.id = buildlog.id
) AS myval_new
ORDER BY id DESC limit 10
变慢是因为它可能选择在进行连接之前进行排序。在外部查询中执行 order by 会强制它仅对选定的项目进行排序。
关于MySQL : Improving query perfomance on join with order by clause,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13139559/
我正在使用 Keras 2.0 包为 Python 训练一个批处理的神经网络。以下是有关数据和训练参数的一些信息: #samples in train: 414934 #features: 59009
我一直在使用 CSS 和 jQuery(简单的 CSS 样式更改,请参阅 here)使事物发光,现在我想知道如何使这些动画变得更好。 目前,我只是在无框阴影和有框阴影之间进行过渡,这看起来不错。但我试
我正在计算几台服务器上的 CPU 使用率。但是计算速度非常非常慢。 这是迄今为止我的代码: While it <= 5 Dim myOptions As New ConnectionOptio
Improved pngnq源归档文件不带有makefile(解压缩时要小心,没有顶层目录)。 如何在openSUSE 11.4上进行编译?安装了libpng/zlib header 和常用的C工具链
我在 MySQL 数据库中有两个表: Book(title, publisher, year) title is primary key Author(name, title) title is fo
public class EntityUtils { private static final Map> searchMap = new HashMap<>(); private st
我们有元素,内置 Extjs 和 scss。我们想提高 scss 的性能。我们使用了 grunt scss-lint,得到以下结果 NestingDepth: Nesting should be no
我有一个包含五个值的数组: "-360°" "0 x" "1r" "0,01 m/s" "0,01 m/s²" 我想提取所有与单位相关的字符串。 我有这个正则表
我创建了一个算法来解决以下问题陈述:问题陈述是: 我们说两个整数 x 和 y 至少有 K 的变化,如果 |x − y| ≥ K(它们差的绝对值至少为K)。给定一个N个整数a1,a2,...,aN和K的
想做个算法,在leetcode上发现了这个问题 Given an array of integers, find two numbers such that they add up to a spec
有什么方法可以增加我的 EditText 的滚动吗?我想让它像在 Web 浏览器上那样滚动,流畅且快速。这可能吗? 谢谢,亚历克斯。 最佳答案 Webview 使用平滑滚动。 ScrollView 也
我的网站有搜索功能。 无论如何,我的网站上有这样的文字:“čurti”“čuožžut”等等...... 问题是,当用户搜索单词“curti”而不是“čurti”时,它应该找到该页面。 一些有助于理解
描述 ifelse() 函数允许通过一系列测试过滤向量中的值,如果结果为正,每个测试都会产生不同的 Action 。例如,让 xx 是一个 data.frame,如下: xx <- data.fram
智能舍入一直是 knitr 的一大特色,可以避免很多 sprintf/round/paste0 走弯路。 在一位客户提示我给出了错误的小数点后,我注意到忘记 $$ 对于可能以科学计数法打印的数字是非常
我想要一个具有快速连接和编辑操作的字符串表示。我已阅读论文 "Ropes: an Alternative to Strings" ,但自 1995 年以来,这方面是否有任何重大改进? 编辑:我之前考虑
我一直在使用 LibGDX 制作一个简单的游戏,现在我尝试在我的游戏中添加一个健康栏。我已经成功在游戏中添加了生命条,目前运行良好。 然而,问题是如何像专业人士一样进一步修改这段代码。我仍在学习过程中
我有一个任务要做。问题是这样的。你给出一个数字,比如x。该程序计算从 1 开始的数字的平方,并且仅当它是回文时才打印它。程序将继续打印这些数字,直到达到您提供的数字 x。 我已经解决了这个问题。它在
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 5 年前。 Improve this ques
这个字符集 [^\/:] // all characters except / or : 弱于 jslint b.c.我应该指定可以使用的字符,而不是根据此 SO Post 不能使用的字符. 这是一个
我正在尝试使用另一个表 (B) 中包含的地址数据对一个表 (A) 中的数据进行地理编码。由于街道名称的书写方式可能不同,我想首先浏览 A 中的数据,并为每个元组在给定的邮政编码区内找到 B 中最接近
我是一名优秀的程序员,十分优秀!