tipos de segmentos. b-tree index index entry header key column length key column value rowid root...
TRANSCRIPT
![Page 1: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/1.jpg)
Tipos de Segmentos
![Page 2: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/2.jpg)
B-Tree Index
Index entry header
Key column length
Key column value
ROWID
Root
Branch
Leaf
Index entry
![Page 3: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/3.jpg)
Almacenamiento en los índices PCTFREE DB_BLOCK_SIZE-OVERHEAD-entries*
ENTRY_ OVERHEAD-ENTRIES(directorio valores)-ROWID
![Page 4: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/4.jpg)
Reescritura de Consultas
![Page 5: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/5.jpg)
Function-Based Indexes
SQL> CREATE INDEX FBI_UPPER_LASTNAME 2 ON CUSTOMERS(upper(cust_last_name));
SQL> SELECT * 2 FROM customers 3 WHERE UPPER(cust_last_name) = 'SMITH';
SQL> ALTER SESSION 2 SET QUERY_REWRITE_ENABLED = TRUE;SQL> ALTER SESSION 2 SET QUERY_REWRITE_ENABLED = enforced | trusted | stale_tolerated ;
![Page 6: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/6.jpg)
Function-Based Indexes: Usage Function-based indexes:
Materialize computational-intensive expressions
Facilitate case-insensitive searches Provide a simple form of data
compression Can be used for an NLS sort index
![Page 7: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/7.jpg)
Índices y nulos
Oracle ignora los registro donde todas las entradas son nulos.
CREATE INDEX IDX1 ON EMPLOYEE(NVL(ename,’null’)
![Page 8: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/8.jpg)
Ejemplo Bitmap- Tabla base
CUSTOMER # MARITAL_ STATUS REGION GENDER INCOME_ LEVEL
101 single east male bracket_1
102 married central female bracket_4
103 married west female bracket_2
104 divorced west male bracket_4
105 single central female bracket_2
106 married central female bracket_3
![Page 9: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/9.jpg)
Ejemplo Bitmap (Bitmap Generado)
REGION='east' REGION='central' REGION='west'
1 0 0
0 1 0
0 0 1
0 0 1
0 1 0
0 1 0
![Page 10: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/10.jpg)
Ejemplo Consulta sobre Bitmap
SELECT COUNT(*) FROM CUSTOMER WHERE MARITAL_STATUS = 'married' AND REGION IN ('central','west');
![Page 11: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/11.jpg)
Bitmap Indexes
<Blue, 10.0.3, 12.8.3, 1000100100010010100>
<Green, 10.0.3, 12.8.3, 0001010000100100000>
<Red, 10.0.3, 12.8.3, 0100000011000001001>
<Yellow, 10.0.3, 12.8.3, 0010001000001000010>
keystartROWID
endROWID bitmap
Table
Index
Block 10
Block 11
Block 12
File 3
![Page 12: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/12.jpg)
Creating Bitmap IndexesCREATE BITMAP INDEX orders_region_id_idx
ON orders(region_id)
PCTFREE 30
STORAGE(INITIAL 200K NEXT 200K
PCTINCREASE 0 MAXEXTENTS 50)
TABLESPACE indx;
![Page 13: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/13.jpg)
Comparing B-Tree andBitmap Indexes
B-tree
Suitable for high-cardinality columns
Updates on keys relativelyinexpensive
Inefficient for queries using OR predicates
Useful for OLTP
Bitmap
Suitable for low-cardinality columns
Updates to key columns veryexpensive
Efficient for queries using OR predicates
Useful for data warehousing
![Page 14: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/14.jpg)
COMPUTE STATISTICS
CREATE INDEX ord_customer_ix_demo
ON orders(customer_id, sales_rep_id)
COMPUTE STATISTICS;
![Page 15: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/15.jpg)
Índices particionados localmente sobre tablas Particionadas
CREATE TABLE employees(employee_id NUMBER(4) NOT NULL, last_name VARCHAR2(10), department_id NUMBER(2)) PARTITION BY RANGE (department_id)(PARTITION employees_part1 VALUES LESS THAN (11) TABLESPACE part1, PARTITION employees_part2 VALUES LESS THAN (21) TABLESPACE part2, PARTITION employees_part3 VALUES LESS THAN (31) TABLESPACE part3);
![Page 16: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/16.jpg)
Índices Particionados Globalmente sobre Tablas Particionadas
CREATE INDEX employees_global_part_idx ON employees(employee_id)GLOBAL PARTITION BY RANGE(employee_id)(PARTITION p1 VALUES LESS THAN(5000), PARTITION p2 VALUES LESS THAN(MAXVALUE));
![Page 17: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/17.jpg)
Índices globales no particionados sobre tablas particionadas
CREATE INDEX employees_global_idx ON employees(employee_id);
![Page 18: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/18.jpg)
Hash-Partitioned Global Indexes: Overview 10g
1000, 1001, …900, 901, …< 1000 < MAXVALUE
901, 1001, …900, 1000, …
Range-partitioned global index
Hash-partitioned global index
![Page 19: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/19.jpg)
Creating Hash-Partitioned Global IndexesSQL> CREATE INDEX ghoi_ix 2 ON order_items (order_id) GLOBAL 3 PARTITION BY HASH (order_id) ( 4 PARTITION p1 TABLESPACE tbs_1, 5 PARTITION p2 TABLESPACE tbs_2, 6 PARTITION p3 TABLESPACE tbs_3, 7 PARTITION p4 TABLESPACE tbs_4);
SQL> CREATE INDEX ghoi_ix 2 ON order_items (order_id) GLOBAL 3 PARTITION BY HASH (order_id) 4 PARTITIONS 4 5 STORE IN (tbs_1, tbs_2, tbs_3, tbs_4);
![Page 20: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/20.jpg)
Índices Bipmap para IOT
Tabla de Correspondencia
9i Hash, rango
10g Lista
ROWID Físico ROWID Lógico
![Page 21: Tipos de Segmentos. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry](https://reader036.vdocument.in/reader036/viewer/2022062421/56649cd95503460f949a33a4/html5/thumbnails/21.jpg)
Creación de una Tabla Particionada Organizada por ÍndiceCREATE TABLE sales_range(
salesman_id NUMBER(5), salesman_name VARCHAR2(30), sales_amount NUMBER(10), sales_date DATE, PRIMARY KEY(sales_date, salesman_id)) ORGANIZATION INDEX INCLUDING salesman_id OVERFLOW TABLESPACE tabsp_overflow PARTITION BY RANGE(sales_date)(PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY')) OVERFLOW TABLESPACE p1_overflow, PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY')) OVERFLOW TABLESPACE p2_overflow, PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY')) OVERFLOW TABLESPACE p3_overflow, PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY')) OVERFLOW TABLESPACE p4_overflow);