MySQL索引下推技術

来源:http://www.cnblogs.com/ivictor/archive/2016/02/18/5197434.html
-Advertisement-
Play Games

索引下推整個思路如下: To see how this optimization works, consider first how an index scan proceeds when Index Condition Pushdown is not used: Get the next row,


索引下推整個思路如下:

To see how this optimization works, consider first how an index scan proceeds when Index Condition Pushdown is not used:

  1. Get the next row, first by reading the index tuple, and then by using the index tuple to locate and read the full table row.

  2. Test the part of the WHERE condition that applies to this table. Accept or reject the row based on the test result.

When Index Condition Pushdown is used, the scan proceeds like this instead:

  1. Get the next row's index tuple (but not the full table row).

  2. Test the part of the WHERE condition that applies to this table and can be checked using only index columns. If the condition is not satisfied, proceed to the index tuple for the next row.

  3. If the condition is satisfied, use the index tuple to locate and read the full table row.

  4. Test the remaining part of the WHERE condition that applies to this table. Accept or reject the row based on the test result.

舉例如下:

Suppose that we have a table containing information about people and their addresses and that the table has an index defined as INDEX (zipcode, lastname, firstname). If we know a person's zipcode value but are not sure about the last name, we can search like this:

SELECT * FROM people
  WHERE zipcode='95054'
  AND lastname LIKE '%etrunia%'
  AND address LIKE '%Main Street%';

people表中(zipcode,lastname,firstname)構成一個索引。

如果沒有使用索引下推技術,則MySQL會通過zipcode='95054'從存儲引擎中查詢對應的元祖,返回到MySQL服務端,然後MySQL服務端基於lastname LIKE '%etrunia%'和

address LIKE '%Main Street%'來判斷元祖是否符合條件。

如果使用了索引下推技術,則MYSQL首先會返回符合zipcode='95054'的索引,然後根據lastname LIKE '%etrunia%'和address LIKE '%Main Street%'來判斷索引是否符合

條件。如果符合條件,則根據該索引來定位對應的元祖,如果不符合,則直接reject掉。

 

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 代碼: RootViewController.m #import "RootViewController.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName
  • 主要是對項目中用過的 oracle 函數進行總結,並做出目錄,方便後續項目是快速查找,提高效率。 01.Round (數值的四捨五入) 描述:傳回一個數值,該數值是按照指定的小數位元數進行四捨五入運算的結果。 SELECT Round(Number,[Decimal_Places])FROM Dua
  • 2張數據表:訂單Order,訂單進度OrderProgress 設計思路一、 1.Order:oid,userid,postInfo,isDel 2.OrderProgress:opId,oid,createTime,PayTime,isDel 這麼設計,oid做外鍵,當拿到一個Order對象,在M
  • 有時,為了讓應用程式運行得更快,所做的全部工作就是在這裡或那裡做一些很小調整。但關鍵在於確定如何進行調整!遲早您會遇到這種情況:應用程式中的 SQL 查詢不能按照您想要的方式進行響應。它要麼不返回數據,要麼耗費的時間長得出奇。如果它降低了企業應用程式的速度,用戶必須等待很長時間。用戶希望應用程式響應
  • 概述 本章節主要介紹配置HaProxy+Keepalived高可用群集,Mycat的配置就不在這裡做介紹,可以參考我前面寫的幾篇關於Mycat的文章。 部署圖: 配置 HaProxy安裝 181和179兩台伺服器安裝haproxy的步驟一致 --創建haproxy用戶 useradd haproxy
  • 最近看到有部分人MongoDB安裝之後總是啟動不起來,在這裡,寫了一個簡單的搭建教程 直接進入正題 1.mongoDB下載地址 https://www.mongodb.org/downloads#production 2.安裝 預設安裝目錄在 C:\Program Files\MongoDB\ 中,
  • Memcached是一個高併發的記憶體鍵值對緩存系統,它的主要作用是將資料庫查詢結果,內容,以及其它一些耗時的計算結果緩存到系統記憶體中,從而加速Web應用程式的響應速度。 Memcached最開始是作為Linux應用程式被安裝在Linux伺服器上來使用的,不過自從開源之後,它又被重新編譯以適用於Win
  • 1、oracel 查看表空間使用情況。 SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name FROM dba_free_space GROUP BY tablespace_name; SELECT a.tablespace...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...