Home Database Mysql Tutorial 关于分区技术的索引index

关于分区技术的索引index

Jun 07, 2016 pm 04:02 PM
index about Partition technology series index

分区系列篇: 关于oracle分区技术--初了解 http://blog.csdn.net/wanghui5767260/article/details/39158873 关于分区技术的索引: http://blog.csdn.net/wanghui5767260/article/details/39181027 关于分区技术---索引 Index 一、 分区索引分类: 本地前缀分

分区系列篇:

关于oracle分区技术--初了解 http://blog.csdn.net/wanghui5767260/article/details/39158873

关于分区技术的索引: http://blog.csdn.net/wanghui5767260/article/details/39181027

关于分区技术---索引 Index

一、 分区索引分类:

本地前缀分区索引(local prefixedpartitioned index)

全局分区索引(global partitionedindex)

本地非前缀分区索引(localnon-prefixed partitioned index)

1.1 表和索引的组合:

\

第一种:表和索引都不分区

最简单的方式 就是常见的索引

第二种:表分区了,但索引没分区

这导致了:“我们已经做了分区表了,怎么性能没有提高?”的主要原因之一。

在很多系统中,特别是交易系统里面,是通过索引访问数据库的。如果索引没有分区,索引树的高度没有变,因此访问性能当然没有提高。如果按索引访问表,与表是否分区关系不大。

第三种:表没有分区,但索引分区了

索引只能是全局分区索引。

第四种:表分区了,索引也分区了(重点!!!)

全局分区索引

本地前缀分区索引

二、 具体介绍分区索引

本地分区索引

是指索引的分区方法与对应表的分区方法一样。

2.1本地前缀分区索引(local prefixed partitioned index)

是指分区字段是索引字段的前缀。

一张交易流水表(TXN_CURRENT),并且以交易日期字段(TXN_DATE)按年度进行了范围分区。在TXN_DATE 字段创建索引。

Createindex idx_txn_current_1 on txn_current(txn_date) local;

或者复合分区索引

Createindex idx_txn_current_2 on txn_current(txn_date,area) local;

好处:

a. 由于分区索引和表分区对应,因此查询数据直接到对应的索引分区去查询,索引树的高度肯定低于非分区情况下的那棵大索引树了,也就是说性能更高了。

b. 当某个分区进行删除(DROP)或合并(MERGE)操作之后,oracle自动对所对应的索引分区进行相同的操作,整个本地前缀索引依然有效,不需要重建(rebuild)操作,这样大大保障了表的可用性。

2.2 全局分区索引(global partitioned index)

索引的分区与表分区无关

分区表按年份进行分区,在地区(AREA)字段上建立分区索引,

 \

也就是说:杭州交易数据肯定可分布在各年份,湖州、嘉兴交易数据同样如此。

假如有这样的查询需求:

Select* from TXN_CURRENT where area=’05711001’;

--假设查询杭州西湖区

好处:

a. 此时oracle会很聪明地知道杭州的分区索引树上去检索,索引高度肯定低于非分区情况下的大索引树了,也就是性能更高了。

b. 在分区粒度比较细的情况下,性能甚至高于本地前缀分区索引。

不足:

a. 主要体现在高可用方面。如果该表的03年数据通过分区删除全部删除了。则全局分区索引(包括普通非分区索引)则全部失效(INVALID),这些索引不可用了,除非重建(rebuild)操作。数据量越大,索引量也越大,重建索引时间也越长,无法通过该类索引访问数据的时间也越长。因此,大大降低数据的可访问性。

2.3 本地非前缀分区索引

可能导致性能会下降的情况,本地非前缀分区索引的性能可能还不如不分区。

优点:

a. 提高按索引访问的可用性!我们假设要通过删除分区技术,进行03年数据的清理,如果area字段索引建立成普通索引,或者是全局分区索引,都会面临一个问题:在分区删除(DROP)操作之后,普通索引和全局分区索引都会失效(INVALID),必须重建。而本地非前缀分区索引的好处在于,在分区删除操作后,该本地非前缀分区索引依然有效。

三、 整理思路

理解分区索引藏宝图:

\

描述藏宝图:找宝藏

(1)如果表分区字段正好是索引字段或者是其前缀。例如:上述TXN_CURRENT 表分区字段是TXN_DATE,则TXN_DATE正好是索引字段(TXN_DATE),或者正好是索引字段(TXN_DATE,AREA)的前缀,则此时应建立local profixedpartitioned index.

(2)否则,如果欲将非分区字段建立为唯一索引,例如:假设在TXN_CURRENT 表的某个字段建立唯一索引,oracle要求必须global prefixed index.

否则报错:

ORA-14039:partitioning columns must form a subset of key columns of a UNIQUE index

(3)流程图再往下,此时要判断“是否性能在可承受范围,而分区的管理性、可用性更重要?”。如果是,就应建立local non-profixed index。也就是上面所描述的:如果历史数据的整理非常频繁,而且不能承受全局分区索引重建的长时间带来的索引不可用,同时日常交易性能尚能接受,则建议设计为本地非前缀分区索引。

(4)流程图再往下,最后判断系统是否为交易系统或者是数据仓库系统。因为通常情况下,数据仓库会有频繁的大批量数据导入(ETL)操作,以及历史数据清理操作,此时分区索引可用性更重要,因此建议设计为Localnon-profixed index 。而在交易系统中,日常查询性能要求更高,历史数据清理操作频度相对较低,因此建议设计为global profixed index。

注:oracle没有global non-profixed index概念。

四、 分区表设计建议 只是建议:更多看实际!!!

(1) 表的大小:当表的大小超过1.5G—2GB时,或对于OLTP系统,表的记录超过1000万条时,都应考虑对表进行分区。

(2) 数据访问特征:基于表的大部分查询应用,只访问表中的少量数据。对于这样的表进行分区,可充分利用分区技术排除无关数据查询的特征。

(3) 数据维护:按时间段删除成批的数据,例如按月删除历史数据。对于这样的表需要考虑进行分区,以满足维护的需求。

(4) 数据备份和恢复:按时间周期进行表空间的备份时,在分区与表空间之间建立起对应关系。

(5) 只读数据:如果一个表中的大部分数据都是只读数据,通过对表进行分区,可将只读数据存储在只读表空间中,对于数据库的备是非常有益的。

(6) 并行数据操作:对于经常执行并行操作(如parallelinsert、parallel update等)的表应考虑进行分区。

(7) 表的可用性:当对表中部分数据的可用性要求很高时,应考虑进行表分区。

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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
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)

What file is index.html? What file is index.html? Feb 19, 2024 pm 01:36 PM

index.html represents the home page file of the web page and is the default page of the website. When a user visits a website, the index.html page is usually loaded first. HTML (HypertextMarkupLanguage) is a markup language used to create web pages, and index.html is also an HTML file. It contains the structure and content of a web page, as well as tags and elements used for formatting and layout. Here is an example index.html code: &lt

This article is enough for you to read about autonomous driving and trajectory prediction! This article is enough for you to read about autonomous driving and trajectory prediction! Feb 28, 2024 pm 07:20 PM

Trajectory prediction plays an important role in autonomous driving. Autonomous driving trajectory prediction refers to predicting the future driving trajectory of the vehicle by analyzing various data during the vehicle's driving process. As the core module of autonomous driving, the quality of trajectory prediction is crucial to downstream planning control. The trajectory prediction task has a rich technology stack and requires familiarity with autonomous driving dynamic/static perception, high-precision maps, lane lines, neural network architecture (CNN&GNN&Transformer) skills, etc. It is very difficult to get started! Many fans hope to get started with trajectory prediction as soon as possible and avoid pitfalls. Today I will take stock of some common problems and introductory learning methods for trajectory prediction! Introductory related knowledge 1. Are the preview papers in order? A: Look at the survey first, p

The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora? The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora? Mar 06, 2024 pm 05:34 PM

StableDiffusion3’s paper is finally here! This model was released two weeks ago and uses the same DiT (DiffusionTransformer) architecture as Sora. It caused quite a stir once it was released. Compared with the previous version, the quality of the images generated by StableDiffusion3 has been significantly improved. It now supports multi-theme prompts, and the text writing effect has also been improved, and garbled characters no longer appear. StabilityAI pointed out that StableDiffusion3 is a series of models with parameter sizes ranging from 800M to 8B. This parameter range means that the model can be run directly on many portable devices, significantly reducing the use of AI

DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! Mar 21, 2024 pm 05:21 PM

This paper explores the problem of accurately detecting objects from different viewing angles (such as perspective and bird's-eye view) in autonomous driving, especially how to effectively transform features from perspective (PV) to bird's-eye view (BEV) space. Transformation is implemented via the Visual Transformation (VT) module. Existing methods are broadly divided into two strategies: 2D to 3D and 3D to 2D conversion. 2D-to-3D methods improve dense 2D features by predicting depth probabilities, but the inherent uncertainty of depth predictions, especially in distant regions, may introduce inaccuracies. While 3D to 2D methods usually use 3D queries to sample 2D features and learn the attention weights of the correspondence between 3D and 2D features through a Transformer, which increases the computational and deployment time.

[Linux system] fdisk related partition commands. [Linux system] fdisk related partition commands. Feb 19, 2024 pm 06:00 PM

fdisk is a commonly used Linux command line tool used to create, manage and modify disk partitions. The following are some commonly used fdisk commands: Display disk partition information: fdisk-l This command will display the partition information of all disks in the system. Select the disk you want to operate: fdisk/dev/sdX Replace /dev/sdX with the actual disk device name you want to operate, such as /dev/sda. Create new partition:nThis will guide you to create a new partition. Follow the prompts to enter the partition type, starting sector, size and other information. Delete Partition:d This will guide you to select the partition you want to delete. Follow the prompts to select the partition number to be deleted. Modify Partition Type: This will guide you to select the partition you want to modify the type of. According to mention

Xiaomi 15 series full codenames revealed: Dada, Haotian, Xuanyuan Xiaomi 15 series full codenames revealed: Dada, Haotian, Xuanyuan Aug 22, 2024 pm 06:47 PM

The Xiaomi Mi 15 series is expected to be officially released in October, and its full series codenames have been exposed in the foreign media MiCode code base. Among them, the flagship Xiaomi Mi 15 Ultra is codenamed "Xuanyuan" (meaning "Xuanyuan"). This name comes from the Yellow Emperor in Chinese mythology, which symbolizes nobility. Xiaomi 15 is codenamed "Dada", while Xiaomi 15Pro is named "Haotian" (meaning "Haotian"). The internal code name of Xiaomi Mi 15S Pro is "dijun", which alludes to Emperor Jun, the creator god of "The Classic of Mountains and Seas". Xiaomi 15Ultra series covers

How to increase WinRE partition size in Windows 11 How to increase WinRE partition size in Windows 11 Feb 19, 2024 pm 06:06 PM

In this article, we will show you how to change or increase WinRE partition size in Windows 11/10. Microsoft will now update Windows Recovery Environment (WinRE) alongside monthly cumulative updates, starting with Windows 11 version 22H2. However, not all computers have a recovery partition large enough to accommodate the new updates, which can cause error messages to appear. Windows Recovery Environment Service Failed How to Increase WinRE Partition Size in Windows 11 To increase WinRE partition size manually on your computer, follow the steps mentioned below. Check and disable WinRE Shrink OS partition Create new recovery partition Confirm partition and enable WinRE

Detailed explanation of how to set up Linux Opt partition Detailed explanation of how to set up Linux Opt partition Mar 20, 2024 am 11:30 AM

How to set up the Linux Opt partition and code examples In Linux systems, the Opt partition is usually used to store optional software packages and application data. Properly setting the Opt partition can effectively manage system resources and avoid problems such as insufficient disk space. This article will detail how to set up a LinuxOpt partition and provide specific code examples. 1. Determine the partition space size. First, we need to determine the space size required for the Opt partition. It is generally recommended to set the size of the Opt partition to 5%-1 of the total system space.

See all articles