- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下是来自 MySQL Documentation 的文字:
- To find the
MIN()
orMAX()
value for a specific indexed column key_col. This is optimized by a preprocessor that checks whether you are using WHERE key_part_N = constant on all key parts that occur before key_col in the index. In this case, MySQL does a single key lookup for eachMIN()
orMAX()
expression and replaces it with a constant. If all expressions are replaced with constants, the query returns at once. For example:
SELECT MIN(key_part2),MAX(key_part2)
FROM tbl_name WHERE key_part1=10;
To sort or group a table if the sorting or grouping is done on a leftmost prefix of a usable index (for example, ORDER BY key_part1, key_part2). If all key parts are followed by
DESC
, the key is read in reverse order.In some cases, a query can be optimized to retrieve values without consulting the data rows. (An index that provides all the necessary results for a query is called a covering index.) If a query uses from a table only columns that are included in some index, the selected values can be retrieved from the index tree for greater speed:
SELECT key_part3 FROM tbl_name
WHERE key_part1=1
我根本无法理解这些要点以及 MySQL Documentation 中的相应代码.
有人请让事情变得简单,以便澄清事情让我理解。
我不是在问什么是索引以及如何工作等等。
我只想了解这些句子试图表达的意思以及代码中发生了什么?
key_par_N 是什么,在这里使用它们的目的是什么?
在此上下文中,术语关键部分的实际含义是什么?
索引中 key_col 之前出现的所有关键部分是什么意思?
我们应该对 MIN()
和 MAX()
进行罚款的列 key_col 在哪里值(查看第一行: 查找特定索引列的 MIN()
或 MAX()
值 key_col.)?
有人请让我清楚一切。
注意:我已经看到了 this问题是问同样的事情,但它收到了一个普遍的答案,这个答案并不特定于手册中给出的解释和代码。所以,我问这个问题是为了得到准确和具体的答案。所以,请不要将我的问题标记为重复。
最佳答案
在 SQL 中,您可以创建索引以索引多个列,例如,create index idx on t1 (key_colX, key_colY)
。现在 key_part1 是 key_colX
而 key_part2 是 key_colY
。顺序很重要!
假设我们使用一个 bTree 作为索引结构,然后首先根据 key_part1 组织元素,如果两个元素的 key_part1 相等则根据 key_part2。现在,如果您发出查询并将 key_part1 = 10 设置为(常数)值,数据库可以快速找到 bTree 的子树,其中 key_part1 = 10。此子树中的所有元素都根据 key_part2 进行组织,这使得 Min() 或Max() 非常有效。
如果你用另一种方式尝试查询
SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name WHERE key_part2=10;
那么索引就不能使用了。
所以上面基本上说如果您的查询可以利用索引列的顺序,您可以更有效地回答查询。
关于mysql - 索引如何工作以查找特定索引列的 MIN() 或 MAX() 值并在以下情况下对表进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47690334/
这个问题在这里已经有了答案: standalone parentheses in javascript [duplicate] (5 个答案) 关闭 8 年前。 我在学习JavaScript,有时会
我是mysql新手,我必须减少以下更新查询的执行时间 UPDATE temp_countcalculations, ( SELECT count(*) as insuffcounts,CRP_
def escape_html(s): for (i, o) in (("&","&"),(">", ">"),(" "变成 ">"等。 关于python - 以下 for 循环
if (read(read(cin, data1), data2)) 问题是C++ Primer 5th Edition 的练习。 read 函数定义如下: std::istream &read(st
我想创建两个宏。其中一个将扩展到函数原型(prototype)和函数内容,另一个将扩展到仅函数原型(prototype)。我正在考虑创建以下内容: #ifdef SOME_CONDITION #def
我正在使用 jongo API - org.jongo.MongoCollection 是类。 我有对象 ID 列表并转换为与 ObjectId[] 相同并尝试按如下方式查询 collection.f
有人可以解释以下正则表达式匹配什么吗? ^.*$ 谢谢! 最佳答案 或者整个字符串或者整行,取决于是否multiline mode被使用。 关于java - 以下 ^.*$ 正则表达式匹配什么?,我们
#include void main() { int a,b,c; for(b = c = 10; a = "- FIGURE?, UMKC,XYZHello Folks,TFy!QJ
我的代码段中的以下代码行被 Sonar 检测为问题。 代码段: final int Pending=1; Sonar 问题: Name 'Pending' must matc
Print name of all activities with neither maximum nor minimum number of participants 我尝试了以下查询,但出现错误:
这个问题在这里已经有了答案: What is this practice called in JavaScript? (7 个回答) 关闭8年前。 (function() { //do stuff
根据任务,我们必须通过 foldr 实现 foldl。通过比较函数签名和 foldl 实现,我得到了以下解决方案: myFoldl :: (a -> b -> a) -> a -> [b] -> a
这个问题在这里已经有了答案: Export an es6 default class inline with definition or at end of file? (1 个回答) 关闭 2 年
据我了解,以下是相同的: Person p{}; // Case 1 Person p = {}; // Case 1.5 我注意到 Person p = Person{}; // Case 2 产生
below i have given a javascript code picture `` can any one help me in this code. what do this code.
我想在标题和正文上搜索全文,并在答案计数上进行过滤。 我阅读了elasticsearch documentation for combining filters并构建了此查询。 "query": {
它是流动的 C 代码中的内存泄漏吗? #include int *a; int main() { a = malloc(sizeof(int)*10); return
这两个声明有什么区别: char (*ptr)[N]; 对比 char ptr[][N]; 谢谢。 最佳答案 (1)声明 char (*ptr)[N]; ptr 是指向大小为 N 的字符数组的指针 下
data II = I Int Int deriving (Show) instance II Show where show I a b = show (a+b) showt.hs:3:2: s
我从 clojuredoc 中阅读了关于 condp 的文档。在文档中我找到了以下代码: (condp 一些 [1 2 3 4] #{0 6 7} :>> 公司 #{4 5 9} :>> 十二月 #{
我是一名优秀的程序员,十分优秀!