- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一张 OrderDish 表,其中包含:
create table OrderDish(
email VARCHAR(80),
nOrd integer,
totalPrice integer,
sale integer,
nameR VARCHAR(80),
dayO integer,
monthO VARCHAR(45),
yearO integer,
constraint c5 primary key (email, nOrd),
foreign key (email) references Client(email),
foreign key (nameR) references Restaurant(nameR),
foreign key (dayO, monthO, yearO) references Data(dayO, monthO, yearO));
我有一个非常常见的查询,它询问餐厅和年份销售的 totalPrice
。
select O.nameR, O.yearO, sum(O.totalPrice) as mytotal
from OrderDish O
group by O.nameR, O.yearO;
结果是:
+------------------------------+------+------------+
| nameR | yeaO | mytotal |
+------------------------------+------+------------+
| El Gordo | 2013 | 5699 |
| El Gordo | 2014 | 2793 |
| El Gordo | 2015 | 11457 |
| Eleven | 2013 | 7599 |
| Eleven | 2014 | 3724 |
........
我想创建一些索引来加速这个非常常见的查询。到目前为止我已经这样做了
create INDEX tot_per_rest_per_year
ON OrderDish(nameR) using btree;
但这并没有加速——消耗的时间是一样的。
最佳答案
我认为遵循 INDEX 可以帮助您。
ALTER TABLE OrderDish ADD INDEX(nameR, yearO, totalPrice);
你是全盘扫描,即使有INDEX(nameR)
。
引用http://dev.mysql.com/doc/refman/5.5/en/group-by-optimization.html
Assume that there is an index idx(c1,c2,c3) on table t1(c1,c2,c3,c4). The loose index scan access method can be used for the following queries:
SELECT c1, c2 FROM t1 GROUP BY c1, c2;
SELECT DISTINCT c1, c2 FROM t1;
SELECT c1, MIN(c2) FROM t1 GROUP BY c1;
SELECT c1, c2 FROM t1 WHERE c1 < const GROUP BY c1, c2;
SELECT MAX(c3), MIN(c3), c1, c2 FROM t1 WHERE c2 > const GROUP BY c1, c2;
SELECT c2 FROM t1 WHERE c1 < const GROUP BY c1, c2;
SELECT c1, c2 FROM t1 WHERE c3 = const GROUP BY c1, c2;
和,
" i only know btree in mysql "
MySQL只支持B-TREE INDEX(除了MEMORY Table只支持HASH INDEX)
关于mysql - 索引 btree 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20483576/
我的数学需要一点帮助,这几天我的大脑很痛。 我为许多 btree 的不同大小的节点使用了一个池。如果 btrees 对于大树和小树的每个节点的键平均数量往往相同,那么效果会很好。但是,如果分布不同,我
任何人都可以帮助消除此段错误。我已经在这个代码上工作了一个星期仍然无法调试它。这段代码是Btree的实现。插入部分工作正常,但删除部分出现段错误。我无法调试它,有人可以帮忙吗? 我已经根据此链接给出了
任何人都可以帮助消除此段错误。我已经在这个代码上工作了一个星期仍然无法调试它。这段代码是Btree的实现。插入部分工作正常,但删除部分出现段错误。我无法调试它,有人可以帮忙吗? 我已经根据此链接给出了
我正在尝试按级别顺序打印一棵 b 树,但它一直在崩溃。我不确定真正的原因是什么,但我认为它崩溃是因为指针。我正在尝试使用我在网上找到的一个函数,该函数遍历每个级别并将其放入队列中并打印出来,但我遇到了
我一直在阅读@XenphYan 的回答 How does database indexing work? 但是有些事情我无法理解 Due to the fact that a number of re
我想要一个在一个字段上进行全文搜索然后在不同字段上进行排序的查询(想象一下搜索一些文本文档并按发布日期排序)。该表有大约 1700 万行,它们或多或少按日期均匀分布。这将在 webapp 请求/响应周
让我们看两个表: CREATE TABLE `orders_products` ( `ORDER_ID` int(10) unsigned NOT NULL, `PRODUCT_ID
我正在尝试创建一个为 BTree 设置动画的 Java 小程序。我有创建树的代码,但现在我正在尝试显示它。我认为最简单的方法是按级别打印,但我不知道该怎么做。下面的代码是我的节点的构造函数。另外,如果
我在维基百科上读到的: In B-trees, internal (non-leaf) nodes can have a variable number of child nodes within s
我一直在 slady.net 玩非常酷的 btree applet| .我无法理解特定行为。看看这个起始状态: alt text http://www.freeimagehosting.net/upl
您好,这是我的 SearchTree 类中的代码。Node* 是一个 m_info 类型为 int 的结构体,m_left(smaller nodes by info) 和 m_right(bigge
想象一下,每天都会有一位作者送给您一本新书。这本书正在编写中。他没有告诉您他更改或添加了什么。 您的工作是确定更改和添加内容,然后仅将这些内容传递给出版商(出版商没有时间每天阅读整本书) 为了解决这个
所以我有一个包含大约 2000 万个键值对的列表,我将数据以不同的方式存储在几个 MapDB 中,以查看它如何影响我的程序性能,并进行实验。 问题是,将 2000 万个键值对插入(以随机顺序)到 ma
我找不到关于 Postgres 文档的足够信息,但很想知道 btree 索引对于 postgres varchar 列是怎样的。 任何链接/解释都可能有帮助。 PS:对不起,这个问题含糊不清 最佳答案
我曾尝试查找类似的问题,但没有找到任何问题,除了有关同一列的两个索引的问题(一般而言)。 假设我们有一个包含 COL 列的表。该表(以及整个数据库)对于客户端来说是只读的(让我们假设它更新一次/每隔很
我正在尝试实现 BTree。我几乎已经完成了这棵树,并且对于较小的输入效果很好,这意味着我已经在内存中实现了这棵树。现在我想玩大输入,为此我必须将树写入文件。我不知道从哪里开始。我正在使用 Java,
我有一张 OrderDish 表,其中包含: create table OrderDish( email VARCHAR(80), nOrd integer, totalPri
如何解决这个问题? 我的表结构: CREATE TABLE IF NOT EXISTS `tbl_foster_network` ( `network_id` int(11) NOT NULL C
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我尝试使用 Java 来实现教科书《算法简介》第三版中的算法,但没有取得很大成功。几乎每次我尝试实现它们时,我都会遇到大量错误,以至于我不确定作者自己是否尝试过实现他们自己的伪代码。但具体来说,在这种
我是一名优秀的程序员,十分优秀!