`
zhang_xzhi_xjtu
  • 浏览: 526158 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

oracle概念_索引

    博客分类:
  • db
阅读更多
Index

使用索引可以大大提高数据库的性能。

Primary and unique keys automatically have indexes.

复合索引的列顺序问题。组合列中在前面的列在where子句中查询才会走索引。


B-Tree Indexes 典型的B-Tree索引。

Full Index Scan:可以消除排序,因为index本身已经排序。


Suppose that an application runs the following query:

SELECT department_id, last_name, salary
FROM   employees
WHERE  salary > 5000
ORDER BY department_id, last_name;
Also assume that department_id, last_name, and salary are a composite key in an index. Oracle Database performs a full scan of the index, reading it in sorted order (ordered by department ID and last name) and filtering on the salary attribute. In this way, the database scans a set of data smaller than the employees table, which contains more columns than are included in the query, and avoids sorting the data.



Fast Full Index Scan:只扫描Index table,因为Index table已经包含了所有要返回的数据。
A fast full index scan is a full index scan in which the database reads the index blocks in no particular order. The database accesses the data in the index itself, without accessing the table.


Index Range Scan
Index Unique Scan

Index Skip Scan:customers table的cust_gender列不是M就是F,该表有一个复合索引(cust_gender, cust_email).
那么以下这个查询
SELECT * FROM sh.customers WHERE cust_email = 'Abbey@company.com';
数据库自己优化为:
SELECT * FROM sh.customers WHERE cust_gender = 'F'
  AND cust_email = 'Abbey@company.com'
UNION ALL
SELECT * FROM sh.customers WHERE cust_gender = 'M'
  AND cust_email = 'Abbey@company.com';

Reverse Key Indexes:反转Index key的存储。对于没有反转的index,连续值的index会插入在同一或者相近的block里,造成竞争。而反转的index,连续的index被分散存储。但是同时,Reverse Key Indexes丢失了range scan的能力。


Index Clustering Factor:衡量索引的聚集性,该值越低,则一个范围内的索引更倾向于指向同一个数据块(data block)。

索引的顺序:索引可以定义存储时的顺序,升序或者降序。

Key Compression:索引的Key的存储可以重新排列以节省空间。原有的key可以被分解为prefix entry和suffix entry。

online,0,AAAPvCAAFAAAAFaAAa
online,0,AAAPvCAAFAAAAFaAAg
online,2,AAAPvCAAFAAAAFaAAm
可以排成
online,0
AAAPvCAAFAAAAFaAAa
AAAPvCAAFAAAAFaAAg
online,2
AAAPvCAAFAAAAFaAAm

Bitmap Indexes:对于查询多且取值范围小的列适用。
Bitmap Join Indexes。
Bitmap Storage Structure:一样用B-Tree.
其他书上看到位图索引对于一个值是单行存储的。有可能导致性能问题。
因此改动一个值,会锁行,导致该行所有其他值无法修改。

Function-Based Indexes:基于函数的索引。
Application Domain Indexes:基于应用域的索引,用户可以高度定制。

Index Storage:索引可以任意存储,索引和其索引的表不在同一个tablespace中给表备份带来了方便。

Heap-Organized Table
rows are inserted where they fit。

Index-Organized Tables
叶子节点直接存储row。以PK作为索引。

两种表的对比

Heap-Organized Table
The rowid uniquely identifies a row. Primary key constraint may optionally be defined.
Physical rowid in ROWID pseudocolumn allows building secondary indexes.
Individual rows may be accessed directly by rowid.
Sequential full table scan returns all rows in some order.
Can be stored in a table cluster with other tables.
Can contain a column of the LONG data type and columns of LOB data types.
Can contain virtual columns (only relational heap tables are supported).

Index-Organized Table
Primary key uniquely identifies a row. Primary key constraint must be defined.
Logical rowid in ROWID pseudocolumn allows building secondary indexes.
Access to individual rows may be achieved indirectly by primary key.
A full index scan or fast full index scan returns all rows in some order.
Cannot be stored in a table cluster.
Can contain LOB columns but not LONG columns.
Cannot contain virtual columns.

Index-Organized Tables with Row Overflow Area
Index-Organized Tables中,为了解决行过大问题,可以把一行分为2部分存储。The index entry储存PK和一些可选列,放在index segment里面,The overflow part包含其他的列,放在storage area segment里面。

Secondary Indexes on Index-Organized Tables
logical rowids以PK为基础,所以2级索引可以直接构建在logical rowid之上。

Bitmap Indexes on Index-Organized Tables
0
3
分享到:
评论

相关推荐

    Oracle优化全攻略一【Oracle 索引概念】.docx

    Oracle优化全攻略一【Oracle 索引概念】.docx

    ORACLE9i_优化设计与系统调整

    第一部分 ORACLE系统优化基本知识 23 第1章 ORACLE结构回顾 23 §1.1 Oracle数据库结构 23 §1.1.1 Oracle数据字典 23 §1.1.2 表空间与数据文件 24 §1.1.3 Oracle实例(Instance) 24 §1.2 Oracle文件 26 §1.2.1...

    Oracle_11gR2_概念 oracle白皮书 concept

    第 1 章 Oracle 数据库简介 第 2 章 表和表簇 第 3 章 索引和索引组织表 第 4 章 分区、 视图和其它模式对象 第 5 章 数据完整性 第 6 章 数据字典和动态性能视图

    Oracle索引详解

    Oracle索引详解,索引的初步学习,从无到有。全文分为:索引的概念,创建、删除、修改索引。

    Oracle_Database_11g完全参考手册.part2

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media 作者: (美)Kevin Loney [作译者介绍] ... 第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle_Database_11g完全参考手册.part5

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media 作者: (美)Kevin Loney [作译者介绍] ... 第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle_Database_11g完全参考手册.part3/3

    他的畅销书包括《Oracle Database 11gDBA手册》、Oracle Advanced Tuning and Administration和Oracle SOL&PL;/SQL Annotated Archives。他也为业界的多种杂志撰写了很多技术文章。他经常以贵宾身份出席在北美和...

    Oracle_Database_11g完全参考手册.part2/3

    他的畅销书包括《Oracle Database 11gDBA手册》、Oracle Advanced Tuning and Administration和Oracle SOL&PL;/SQL Annotated Archives。他也为业界的多种杂志撰写了很多技术文章。他经常以贵宾身份出席在北美和...

    Oracle_Database_11g完全参考手册.part3

    基本信息 原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media 作者: (美)Kevin Loney [作译者介绍] ... 第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle_Database_11g完全参考手册.part4

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media 作者: (美)Kevin Loney [作译者介绍] ... 第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle索引

    关于Oracle索引的详细介绍,索引的基本概念,怎么创建单列、符合索引。

    Oracle数据库,索引的相关知识

    1)概念:Oracle数据库中的索引是一种建立在表或簇基础上的数据对象,和表一样具有独立的段存储结构,需要在表空间中为其分配存储空间。 2)作用:可以提高查询表中数据的速度。 2、索引的类型(面试题) 1)B树索引...

    oracle概念手册中英文对照版

    Chapter 18, Partitioned Tables and Indexes 第 18 章,分区表及分区索引 Chapter 19, Content Management 第 19 章,内容管理 Chapter 20, Database Security 第 20 章,数据库安全 Chapter 21, Data Integrity 第...

    Oracle8i_9i数据库基础

    第一部分 Oracle SQL*PLUS基础 23 第一章 Oracle数据库基础 23 §1.1 理解关系数据库系统(RDBMS) 23 §1.1.1 关系模型 23 §1.1.2 Codd十二法则 24 §1.2 关系数据库系统(RDBMS)的组成 24 §1.2.1 RDBMS 内核 24...

    Oracle 基础知识 -大全- 原创整理.pdf

    12.理解索引概念,会建立索引 13.管理oracle的权限和角色 14.理解oracle的PL/SQL概念 15.掌握pl/sql编程技术(包括编写过程、函数、触发器...) 16.掌握pl/sql的高级用法(能编写分页过程模块,下订单过程模块..,) ...

    oracle database 10g 完整参考手册part1

    第17章 创建和管理表、视图、索引、群集和序列 第18章 Oracle基本安全 第Ⅲ部分 高级内容 第19章 高级安全性—— 虚拟专用数据库 第20章 使用表空间 第21章 用SQL*Loader加载数据 第22章 使用Data Pump导入和导出 第...

Global site tag (gtag.js) - Google Analytics