Home Database Mysql Tutorial 通过案例学调优之--Index FULL SCAN和Index FAST FULL SCAN

通过案例学调优之--Index FULL SCAN和Index FAST FULL SCAN

Jun 07, 2016 pm 04:46 PM
scan Case pass

通过案例学调优之--IndexFULLSCAN和IndexFASTFULLSCANIndexFULLSCAN和ndexFASTFULLSCAN工作原理:IndexFULLSCAN和IndexFASTFULLSCAN的适用情况:适用于我们想选


    INDEX FAST FULL SCAN:
HINT写法:INDEX_FFS(表名 索引名)
原理:从段头开始,读取包含位图块,ROOT BLOCK,所有的BRANCH BLOCK,LEAF BLOCK,读取的顺序完全有物理存储位置决定,并采取多块读,每次读取DB_FILE_MULTIBLOCK_READ_COUNT个块。查询某个表记录总数的时候,往往基于PRIMARY KEY的INDEX FAST FULL SCAN是最有效的。

Fast Full Index Scans :
Fast full index scans are an alternative to a full table scan when the index contains all the columns that are needed for the query, and at least one column in the index key has the NOT NULL constraint. A fast full scan accesses the data in the index itself, without accessing the table. It cannot be used to eliminate a sort operation, because the data is not ordered by the index key. It reads the entire index using multiblock reads, unlike a full index scan, and can be parallelized.

Fast full scan is available only with the CBO. You can specify it with the initialization parameter OPTIMIZER_FEATURES_ENABLE or the INDEX_FFS hint. Fast full index scans cannot be performed against bitmap indexes.

A fast full scan is faster than a normal full index scan in that it can use multiblock I/O and can be parallelized just like a table scan.

Full Table Scans : 
This type of scan reads all rows from a table and filters out those that do not meet the selection criteria. During a full table scan, all blocks in the table that are under the high water mark are scanned. Each row is examined to determine whether it satisfies the statement’s WHERE clause.

When Oracle performs a full table scan, the blocks are read sequentially. Because the blocks are adjacent, I/O calls larger than a single block can be used to speed up the process. The size of the read calls range from one block to the number of blocks indicated by the initialization parameter DB_FILE_MULTIBLOCK_READ_COUNT. Using multiblock reads means a full table scan can be performed very efficiently. Each block is read only once.


案例分析:


1、创建表和索引

16:02:10 SYS@ prod >create table t as select * from dba_objects where 1=2; Table created. 16:05:43 SYS@ prod >insert into t select * from dba_objects where object_id is not null; 73025 rows created. 16:06:46 SYS@ prod >select count(*) from t;   COUNT(*) ----------      73025       16:06:56 SYS@ prod >commit; Commit complete. 16:13:48 SYS@ prod >exec dbms_stats.gather_table_stats('SYS','T',cascade=>true); PL/SQL procedure successfully completed. 16:14:33 SYS@ prod >set autotrace trace 16:15:32 SYS@ prod >select object_id from t; 73025 rows selected. Execution Plan ---------------------------------------------------------- Plan hash value: 1601196873 -------------------------------------------------------------------------- | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     | -------------------------------------------------------------------------- |   0 | SELECT STATEMENT  |      | 73025 |   356K|   284   (1)| 00:00:04 | |   1 |  TABLE ACCESS FULL| T    | 73025 |   356K|   284   (1)| 00:00:04 | -------------------------------------------------------------------------- Statistics ----------------------------------------------------------         141  recursive calls           0  db block gets        5857  consistent gets        1038  physical reads           0  redo size     1060958  bytes sent via SQL*Net to client       53963  bytes received via SQL*Net from client        4870  SQL*Net roundtrips to/from client           4  sorts (memory)           0  sorts (disk)       73025  rows processed   从上面的执行计划中可知,此时走了全表扫描。   --由于我们需要查询的列为object_id,因此理论上只需要读取索引就应该可以返回所有数据,而此时为什么是全表扫描呢?   --这是因为NULL值与索引的特性所决定的。即null值不会被存储到B树索引。因此应该为表 t 的列 object_id 添加 not null 约束。         16:16:14 SYS@ prod >desc t;  Name                                                              Null?    Type  ----------------------------------------------------------------- -------- --------------------------------------------  OWNER                                                                      VARCHAR2(30)  OBJECT_NAME                                                                VARCHAR2(128)  SUBOBJECT_NAME                                                             VARCHAR2(30)  OBJECT_ID                                                                  NUMBER  DATA_OBJECT_ID                                                             NUMBER  OBJECT_TYPE                                                                VARCHAR2(19)  CREATED                                                                    DATE  LAST_DDL_TIME                                                              DATE  TIMESTAMP                                                                  VARCHAR2(19)  STATUS                                                                     VARCHAR2(7)  TEMPORARY                                                                  VARCHAR2(1)  GENERATED                                                                  VARCHAR2(1)  SECONDARY                                                                  VARCHAR2(1)  NAMESPACE                                                                  NUMBER  EDITION_NAME                                                               VARCHAR2(30)    在object_id上添加not null约束 16:16:42 SYS@ prod >alter table t modify(object_id not null); Table altered. Elapsed: 00:00:00.34 16:16:46 SYS@ prod >desc t  Name                                                              Null?    Type  ----------------------------------------------------------------- -------- --------------------------------------------  OWNER                                                                      VARCHAR2(30)  OBJECT_NAME                                                                VARCHAR2(128)  SUBOBJECT_NAME                                                             VARCHAR2(30)  OBJECT_ID                                                         NOT NULL NUMBER  DATA_OBJECT_ID                                                             NUMBER  OBJECT_TYPE                                                                VARCHAR2(19)  CREATED                                                                    DATE  LAST_DDL_TIME                                                              DATE  TIMESTAMP                                                                  VARCHAR2(19)  STATUS                                                                     VARCHAR2(7)  TEMPORARY                                                                  VARCHAR2(1)  GENERATED                                                                  VARCHAR2(1)  SECONDARY                                                                  VARCHAR2(1)  NAMESPACE                                                                  NUMBER  EDITION_NAME                                                               VARCHAR2(30)

2、对Index_FS和Index_FFS对比

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Analysis of common web standards and their actual cases Analysis of common web standards and their actual cases Jan 13, 2024 pm 03:50 PM

Understand common Web standards and their practical application cases In today's digital era, the World Wide Web has become an important platform for people to obtain information, communicate, and conduct business activities. Web standards are the basis for ensuring that web pages display normally and operate stably on different browsers. This article will introduce some common web standards and illustrate their importance through practical application cases. First of all, HTML (Hypertext Markup Language) is the most basic part of the Web standards and is used to describe the structure and content of web pages. HTML uses tags to define whether

Solve the problem of environment detection when reinstalling the system Solve the problem of environment detection when reinstalling the system Jan 08, 2024 pm 03:33 PM

How to solve the problem that the environment test fails when reinstalling the system and needs to be rewritten. The reason is: the mobile phone is poisoned. You can install anti-virus software such as Mobile Manager for anti-virus. 2. Many junk files are stored inside the mobile phone, causing the running memory of the mobile phone to be occupied. Just clear the phone cache to solve this problem. 3. The phone memory is occupied too much by saved software and files. It is no problem to delete unnecessary files and software frequently. As long as your hardware configuration meets the installation requirements, you can use the new one directly. Reinstall the system from the system disk! You can use a USB flash drive or hard disk to install, which is very fast. But the key is to use a system disk with good compatibility (supports installation in IDE, ACHI, and RAID modes), and it can be automatically and permanently activated, which has been verified. so

What is the use of the scan method in go language? What is the use of the scan method in go language? Mar 15, 2021 pm 04:46 PM

In the Go language, the Scan() method is used to read text from the standard input "os.Stdin", that is, to obtain data from the terminal. This method will return the number of data successfully read and any errors encountered; if the number of data read is less than the provided parameters, an error report reason will be returned.

Released IoT cases for four consecutive years, Qualcomm and ecological partners jointly draw a new blueprint for the era of digital-real integration Released IoT cases for four consecutive years, Qualcomm and ecological partners jointly draw a new blueprint for the era of digital-real integration Oct 13, 2023 pm 08:25 PM

On busy production lines, robotic arms collaborate efficiently, and operators can easily control the entire process through remote real-time control. Under the mine, technical experts wear AR glasses and use the information displayed in real time in the glasses to quickly solve equipment problems with the technical team thousands of miles away. In the park, unmanned delivery vehicles shuttle freely, allowing users to pick up packages without leaving home. These scenarios are not fictitious, but real cases that appear in the "2023 Qualcomm Empowering Enterprise Digital Transformation Case Collection" recently released by Qualcomm. For four consecutive years, Qualcomm has released the "Internet of Things" focusing on the key development directions and highlight implementation scenarios of the Internet of Things industry. "Application Case Collection" displays the industry's latest technological directions and innovative ecological cooperation models in a multi-dimensional and three-dimensional manner. This year’s case collection focuses on Chinese companies’ use of Qualcomm Technologies

PHP development case: making an online question and answer community PHP development case: making an online question and answer community Oct 27, 2023 am 11:25 AM

In today's Internet age, more and more people like to find answers and communicate with questions online. As a result, various online question and answer communities emerged. These communities provide a platform for users to ask questions, answer questions, and exchange experiences and knowledge with each other. Today, we will introduce the production process of an online Q&A community developed based on PHP. First, we need to clarify what functions an online Q&A community needs to have. Generally speaking, it should include the following aspects: user registration, login, questions, replies

Object-oriented programming cases in PHP Object-oriented programming cases in PHP Jun 11, 2023 am 09:56 AM

As a popular server-side programming language, PHP provides rich object-oriented programming functions. Object-Oriented Programming (OOP) is a programming method that simplifies development and maintenance by dividing a complex system into multiple separate objects. This article will introduce object-oriented programming cases in PHP and demonstrate the application of object-oriented programming in PHP through a simple example. 1. The concept of object-oriented programming In PHP, object-oriented

PHP function library practical case sharing PHP function library practical case sharing Jun 15, 2023 pm 09:06 PM

PHP is a very popular back-end programming language in modern website development. Over time, more and more PHP function libraries have been developed, allowing developers to write programs faster and improve code reusability. In this article, we will share some practical PHP function library cases to help developers better use these function libraries to improve their development efficiency. Alibaba Cloud OSSSDK Alibaba Cloud's Object Storage Service (OSS) is a highly available and highly scalable cloud storage service. Developers can

Practical cases of golang generic programming Practical cases of golang generic programming Jan 20, 2024 am 10:43 AM

Practical application cases of Golang generic programming, requiring specific code examples Introduction: With the development of cloud computing, big data and artificial intelligence, software development engineers face increasing challenges. The generic features of programming languages ​​can provide more efficient and flexible solutions, and Golang, as a modern programming language, has finally introduced support for generic programming in version 1.18. In this article, we will share some practical application cases of Golang generic programming and provide specific code examples. Simplify container implementation

See all articles