为什么全表扫描成本(COST)公式里面要除以sreadtim
全表扫描的成本计算公式 如下: Cost = ( #SRds * sreadtim + #MRds * mreadtim + CPUCycles / cpuspeed ) / sreadtim 全表扫描的时候,单块读次数=0,#SRds表示单块读次数。全表扫描的成本里面,CPU消耗其实非常少,可以忽略不计,所以全表扫描的公式可以改
全表扫描的成本计算公式 如下:
Cost = ( #SRds * sreadtim + #MRds * mreadtim + CPUCycles / cpuspeed ) / sreadtim
全表扫描的时候,单块读次数=0,#SRds表示单块读次数。全表扫描的成本里面,CPU消耗其实非常少,可以忽略不计,所以全表扫描的公式可以改写为:
Cost = #MRds * mreadtim / sreadtim
#MRds 表示多块读io次数
mreadtim 表示一次多块读耗费时间
sreadtim 表示一次单块读耗费时间
全表扫描的COST意思其实就是 多块读io次数 * 多块读时间 / 单块读时间
那么为什么 全表扫描成本公式里面要除以 sreadtim呢? 我们来看一下 索引扫描的成本计算公式:
cost = blevel + celiling(leaf_blocks *effective index selectivity) + celiling(clustering_factor * effective table selectivity)
blevel 是 扫描索引 的 root到branch ---单块读
celiling(leaf_blocks *effective index selectivity) 是扫描的 也在块的个数 ---单块读
ceiling(clustering_factor*effective table selectivity) 是 通过索引的rowid回表的次数 ---单块读
那么 索引扫描的成本公式的本质含义 其实就是 单块读的 io次数
对于单表访问(什么是单表访问? 就是只select一个表),要么走全表扫描,要么走索引扫描,当然了还可以走物化视图(这个不考虑)
ORACLE 究竟是走全表扫描还是走索引扫描呢? 它是计算全表扫描的COST,计算索引扫描的COST 哪个COST消耗少就走哪个。
问题来了,为啥ORACLE计算COST能准确的判断走哪个是最优的呢? 现在我们来比较一下 全表扫描的 COST 与 索引扫描的COST
全表扫描COST 多块读io次数 * 多块读时间 / 单块读时间
索引扫描COST 单块读io次数
那么现在 我们都对 全表扫描 COST , 都对 索引扫描 COST 乘以一个 单块读时间
全表扫描COST* 单块读时间 = 多块读io次数*多块读时间 = 总的耗费时间
索引扫描COST* 单块读时间 = 单块读io次数*单块读时间 = 总的耗费时间
说白了,就是比较全表扫描与索引扫描谁 总的耗费的时间最少,就选谁。
到这里你应该看懂了吧。 不得不佩服ORACLE 设计 人员的头脑,真是牛逼。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

The H5 page needs to be maintained continuously, because of factors such as code vulnerabilities, browser compatibility, performance optimization, security updates and user experience improvements. Effective maintenance methods include establishing a complete testing system, using version control tools, regularly monitoring page performance, collecting user feedback and formulating maintenance plans.

Is JavaScript available to run without HTML5? The JavaScript engine itself can run independently. Running JavaScript in a browser environment depends on HTML5 because it provides the standardized environment required to load and execute code. The APIs and features provided by HTML5 are crucial to modern JavaScript frameworks and libraries. Without HTML5 environments, many JavaScript features are difficult to implement or cannot be implemented.

Discussion on using custom stylesheets in Safari Today we will discuss a custom stylesheet application problem for Safari browser. Front-end novice...

The advantages of H5 page production include: lightweight experience, fast loading speed, and improving user retention. Cross-platform compatibility, no need to adapt to different platforms, improving development efficiency. Flexibility and dynamic updates, no audit required, making it easier to modify and update content. Cost-effective, lower development costs than native apps.

The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

How to solve the display problem caused by user agent style sheets? When using the Edge browser, a div element in the project cannot be displayed. After checking, I posted...

Bootstrap Table garbled is usually because the page encoding is inconsistent with the table data encoding. To solve this problem, you need to make sure they are consistent. The specific steps include: checking page and table data encoding, setting page encoding, and verifying the encoding. If UTF-8 is used, the server should also support it. If it cannot be resolved, try using the JavaScript encoding library.
