Home Database Mysql Tutorial 用示例说明索引数据块中出现热块&Latch的场景,并给出解决方案

用示例说明索引数据块中出现热块&Latch的场景,并给出解决方案

Jun 07, 2016 pm 05:41 PM
latch Appear Scenes data Example index illustrate

引言:索引的热块其实和数据块的热块发生的原理大相径庭,也都是因为大量会话一起访问同一个索引块造成的,我们的解决方案有反向索引,分区索引等。我们说任何一

引言:索引的热块其实和数据块的热块发生的原理大相径庭,也都是因为大量会话一起访问同一个索引块造成的,我们的解决方案有反向索引,分区索引等。我们说任何一种方式都不是完美的,有优点就必然有缺点,我们把包含索引键值的索引块从顺序排列打散到无序排列,香港空间,降低了latch争用,同时也增加了oracle扫描块的数量。我们在实际使用时多测试取长补短,以提高系统的整体性能为目标。


 

LEO1@LEO1>create table leo1 (id  number , name  varchar2(200));     创建了一个leo1表

Table created.

LEO1@LEO1>insert into leo1 (id,name) select object_id,object_name from dba_objects; 将dba_objects前2个字段复制到leo1表中。

71966 rowscreated.

LEO1@LEO1>select id,name from leo1 where rownum

        ID NAME

----------------------------------------------------

       673 CDC_CHANGE_SOURCES$

       674 I_CDC_CHANGE_SOURCES$

       675 CDC_CHANGE_SETS$

       676 I_CDC_CHANGE_SETS$

       677 CDC_CHANGE_TABLES$

       678 I_CDC_CHANGE_TABLES$

       679 CDC_SUBSCRIBERS$

       680 I_CDC_SUBSCRIBERS$

       681 CDC_SUBSCRIBED_TABLES$

LEO1@LEO1>create index leo1_index on leo1(id);     在leo1表上id列创建一个索引

Index created.

LEO1@LEO1>execute dbms_stats.gather_table_stats('LEO1','LEO1',cascade=>true);  对表和索引一起做一个分析,香港空间,cascade=>true 指的是级联表上的索引一起做分析

PL/SQL proceduresuccessfully completed.

LEO1@LEO1>create table leo2 (id number,name varchar2(200));      创建leo2表

Table created.

LEO1@LEO1>insert into leo2 (id,name) select object_id,object_name from dba_objects;  插入71968行

71968 rowscreated.

为什么比leo1表多了2行呢,就是多了leo1和leo1_index这2个对象,我们刚刚建的。

LEO1@LEO1>create index leo2_index on leo2(id) reverse;        创建一个反向索引

Index created.

LEO1@LEO1>execute dbms_stats.gather_table_stats('LEO1','LEO2',cascade=>true);  做分析

PL/SQL proceduresuccessfully completed.

LEO1@LEO1>select index_name,index_type,table_name,status from dba_indexes wheretable_name in ('LEO1','LEO2');

INDEX_NAME   INDEX_TYPE      TABLE_NAME      STATUS

--------------------------------------------------------- ------------------------------ --------

LEO1_INDEX    NORMAL                LEO1           VALID

LEO2_INDEX    NORMAL/REV       LEO2           VALID  

LEO2_INDEX   是反向索引,我们使用它来把顺序的索引块反向成无序索引块存储,这样我们在查询一个区间范围时,索引键值就会落在不连续的索引块上,防止热块的产生,降低“latch 链表”争用。这可能算是反向索引唯一被使用的情况。因为反向索引不支持index range scan功能,只支持index full scan 全索引扫描,如何理解呢,虚拟主机,举个简单的例子 反向索引 不能帮你检索出  id> 1 and id

LEO1@LEO1> set   autotrace  on;       启动执行计划

LEO1@LEO1>select count(*)  from leo1 whereid

  COUNT(*)

----------

        98

Execution Plan

----------------------------------------------------------

Plan hash value:423232053

--------------------------------------------------------------------------------

| Id  | Operation         | Name       | Rows | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------

|   0 | SELECT STATEMENT  |           |     1 |     5 |    2   (0)| 00:00:01 |

|   1 | SORT AGGREGATE   |           |     1|     5 |            |          |

|*  2 |   INDEX RANGE SCAN| LEO1_INDEX |    96 |  480 |     2   (0)| 00:00:01 |

--------------------------------------------------------------------------------

索引范围扫描,因为我们查询索引键值都是存放在连续的索引块中,所以只有仅仅的2个一致性读,它只扫描符合条件的索引块就能找到相应的记录。

PredicateInformation (identified by operation id):

---------------------------------------------------

   2 - access("ID"

Statistics

----------------------------------------------------------

          0 recursive calls

          0 db block gets

          2  consistent gets

          0 physical reads

          0 redo size

        526 bytes sent via SQL*Net to client

        523 bytes received via SQL*Net from client

          2 SQL*Net roundtrips to/from client

          0 sorts (memory)

          0 sorts (disk)

          1 rows processed

LEO1@LEO1>select count(*)  from leo2 whereid

  COUNT(*)

----------

        98

Execution Plan

----------------------------------------------------------

Plan hash value:1710468575

------------------------------------------------------------------------------------

| Id  | Operation             | Name       | Rows | Bytes | Cost (%CPU)| Time     |

------------------------------------------------------------------------------------

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Use ddrescue to recover data on Linux Use ddrescue to recover data on Linux Mar 20, 2024 pm 01:37 PM

DDREASE is a tool for recovering data from file or block devices such as hard drives, SSDs, RAM disks, CDs, DVDs and USB storage devices. It copies data from one block device to another, leaving corrupted data blocks behind and moving only good data blocks. ddreasue is a powerful recovery tool that is fully automated as it does not require any interference during recovery operations. Additionally, thanks to the ddasue map file, it can be stopped and resumed at any time. Other key features of DDREASE are as follows: It does not overwrite recovered data but fills the gaps in case of iterative recovery. However, it can be truncated if the tool is instructed to do so explicitly. Recover data from multiple files or blocks to a single

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

How to solve the long tail problem in autonomous driving scenarios? How to solve the long tail problem in autonomous driving scenarios? Jun 02, 2024 pm 02:44 PM

Yesterday during the interview, I was asked whether I had done any long-tail related questions, so I thought I would give a brief summary. The long-tail problem of autonomous driving refers to edge cases in autonomous vehicles, that is, possible scenarios with a low probability of occurrence. The perceived long-tail problem is one of the main reasons currently limiting the operational design domain of single-vehicle intelligent autonomous vehicles. The underlying architecture and most technical issues of autonomous driving have been solved, and the remaining 5% of long-tail problems have gradually become the key to restricting the development of autonomous driving. These problems include a variety of fragmented scenarios, extreme situations, and unpredictable human behavior. The "long tail" of edge scenarios in autonomous driving refers to edge cases in autonomous vehicles (AVs). Edge cases are possible scenarios with a low probability of occurrence. these rare events

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training Mar 11, 2024 pm 12:10 PM

This week, FigureAI, a robotics company invested by OpenAI, Microsoft, Bezos, and Nvidia, announced that it has received nearly $700 million in financing and plans to develop a humanoid robot that can walk independently within the next year. And Tesla’s Optimus Prime has repeatedly received good news. No one doubts that this year will be the year when humanoid robots explode. SanctuaryAI, a Canadian-based robotics company, recently released a new humanoid robot, Phoenix. Officials claim that it can complete many tasks autonomously at the same speed as humans. Pheonix, the world's first robot that can autonomously complete tasks at human speeds, can gently grab, move and elegantly place each object to its left and right sides. It can autonomously identify objects

See all articles