Example alter table EMP add ( tot_sal number(13) generated always as sal+comm) ... Blog: arup.blogspot.com | Twitter: ar
Are Indexes Unnecessary in Exadata? Arup Nanda Longtime Oracle DBA (and now DMA)
Disclaimer If you downloaded this slide deck, please note: These slides are designed merely as props to help my presentation. They are not intended to stand as independent sources of information. Therefore the contents of the slide deck are not meant to be exhaustive in any way of the content delivered at the session.
Are Indexes Unnecessary in Exadata
2
Quotes You don’t need indexes on Exadata.
Drop all the indexes and reclaim space.
Why? Because there is a storage index. Are Indexes Unnecessary in Exadata
3
3 Questions for “Best Practices”
1. Why it is better than the rest? 2. What happens if it is not followed? 3. When are they not applicable?
Are Indexes Unnecessary in Exadata
4
Storage Index
Are Indexes Unnecessary in Exadata
5
Instances and Databases Instance Combination of •Memory Areas •Background Processes
SELECT NAME FROM CUSTOMERS WHERE STATUS ='ANGRY'
datafile1 datafile2
Storage Are Indexes Unnecessary in Exadata
6
Query Processing
JILL SELECT NAME FROM CUSTOMERS WHERE STATUS ='ANGRY'
datafile1 datafile2
Database Block
Storage
Are Indexes Unnecessary in Exadata
7
Index
Table Are Indexes Unnecessary in Exadata
8
Components for Performance CPU Memory
Less I/O = better performance
Network I/O Controller Disk
Are Indexes Unnecessary in Exadata
9
The Solution • A typical query may: – Select 10% of the entire storage – Use only 1% of the data it gets
• To gain performance, the DB needs to shed weight • It has to get less from the storage Filtering at the storage level The storage must be cognizant of the data
CPU Memory
SELECT NAME FROM CUSTOMERS WHERE STATUS ='ANGRY'
Filtering should be Applied Here
Network I/O Controller Disk
Are Indexes Unnecessary in Exadata
10
CPU
iDB
Memory Network I/O Controller Disk Are Indexes Unnecessary in Exadata
11
iDB
Disk1
Disk2
Disk3
Are Indexes Unnecessary in Exadata
12
Disk1
SELECT … FROM TABLE WHERE COL1 = 2
Disk2
Disk3
MIN = 3
MIN = 4
MIN = 1
MIN = 3
MAX = 5
MAX = 5
MAX = 3
MAX = 5
Disk4
Storage Index Are Indexes Unnecessary in Exadata
13
Storage Indexes • Do not point to the database blocks • Merely stores for a Storage “Unit” – Max/Min Values – Whether nulls are present – For some columns
• Is on Memory of Cells; not disk – Disappears when the cell is down
Are Indexes Unnecessary in Exadata
14
Checking Storage Index Use select name, value/1024/1024 as stat_value from v$mystat s, v$statname n where s.statistic# = n.statistic# and n.name in ( 'cell physical IO bytes saved by storage index', 'cell physical IO interconnect bytes returned by smart scan’) Output STAT_NAME STAT_VALUE ---------- ---------SI Savings 5120.45 Smart Scan 1034.00
Are Indexes Unnecessary in Exadata
15
Offloading and Smart Scan
Offloading Processing to storage cells Smart Scan Reduction in I/O
Are Indexes Unnecessary in Exadata
16
Offloading • Column Projection select cust_id, sale_amt from sales
• Predicate Filtering where status = ‘ANGRY’
• Function Offloading select min(sale_amt)
• Virtual Columns
Are Indexes Unnecessary in Exadata
17
Smart Scan Benefits • Less I/O means – Faster disk access time – Less data from storage to DB – Less buffers – Less CPU – Less data between compute nodes
Are Indexes Unnecessary in Exadata
18
Why Not? • Pre-requisite for Smart Scan – Direct Path – Full Table or Full Index Scan – > 0 Predicates – Simple Comparison Operators
• Other Reasons – Cell is not offload capable • The diskgroup attribute cell.smart_scan_capable set to FALSE;
– Not on clustered tables, IOTs, etc. Are Indexes Unnecessary in Exadata
19
Impact of Data Distribution
SELECT … FROM TABLE WHERE COL1 = 2
MIN = 1
MIN = 1
MIN = 1
MIN = 1
MAX = 5
MAX = 5
MAX = 5
MAX = 5
MIN = 3
MIN = 4
MIN = 1
MIN = 3
MAX = 5
MAX = 5
MAX = 2
MAX = 5
Disk4
Are Indexes Unnecessary in Exadata
20
8 Columns C1 C2 C3 C4 C5 C6 C7 C8
C2 C3 C4 C5 C6 C7 C8 C9
C3 C4 C5 C6 C7 C8 C9 C10 Table T1
Are Indexes Unnecessary in Exadata
21
No Predicate • Aggregations select sum(sale_amt) from sales
Index on SALE_AMT
• Sorting select ... from sales order by sale_amt;
Are Indexes Unnecessary in Exadata
22
Function Based Indexes • Traditional Indexes can’t work select … from sales where to_char(sale_dt,’YY’) = ‘13’
• Function Based Indexes help • SI indexes will not be useful
Are Indexes Unnecessary in Exadata
23
IOTs • Index Organized Tables • PK-based rows • Secondary Indexes built on the other columns
Index
PK Are Indexes Unnecessary in Exadata
Index 24
Clustered Tables
Are Indexes Unnecessary in Exadata
25
Exclusion for SIs • Not for non-equality select sale_amt from sales where status != ‘SHIPPED’
• No Wildcards select sale_amt from sales where city like ‘NEW YORK%’
Are Indexes Unnecessary in Exadata
26
Virtual Columns • Example alter table EMP add ( tot_sal number(13) generated always as sal+comm) )
• Implication – Do not actually exists in the table – Computed at runtime
Are Indexes Unnecessary in Exadata
27
Indexes on Small Tables • Small table – Parameter _small_table_threshold
• Indexes still help small table http://richardfoote.wordpress.com/2009/04/16/indexes-on-small-tablespart-i-one-of-the-few/
– Less latching
Are Indexes Unnecessary in Exadata
28
Summary of SI Limitations • • • • • • • • •
Direct Path not used No Predicate ► No SI No Inequality (!=) ≤ 8 columns No Virtual Columns No wildcard match (LIKE ‘..%’) No IOT, Clustered Table Latching on small tables First-timer Penalty – Only subsequent queries benefit Are Indexes Unnecessary in Exadata
29
Flash Cache These are flash cards presented as disks; not memory to the Storage Cells. They are similar to SAN cache; but Oracle controls what goes on there and how long it stays. alter table person storage (cell_flash_cache keep) datafile1 datafile2
Storage Are Indexes Unnecessary in Exadata
30
Flash Trick for Indexes • Pin Oft-Used Objects in Flash SQL> alter index in_t2 storage (cell_flash_cache keep);
• Check flash CellCLI> > > >
list flashcachecontent attributes – cachedKeepSize, cachedSize, hitCount, hoursToExpiration, missCount where objectnumber = 382380;
• Or, partitions
Are Indexes Unnecessary in Exadata
31
Drop the Index? • Make the indexes invisible SQL> alter index i1 invisible;
– Maintains the index; but optimizer ignores it
• See the performance impact. • Selectively see the impact SQL> alter session set optimizer_use_invisible_indexes = true;
• See the performance impact.
Are Indexes Unnecessary in Exadata
32
Disable • Two parameters – Could be session level
• To disable offloading cell_offload_processing = false;
• To disable storage indexes alone _kcfis_storageidx_disabled = true;
Are Indexes Unnecessary in Exadata
33
In Conclusion • Full table scans in Exadata – may be faster compared to non-Exadata – may not be faster than index scans in Exadata – may benefit from Storage Indexes
• Storage Indexes are not same as DB Indexes • No DB Indexes helps in some cases – But not all
• Test by making DB Indexes invisible • Force FTS in those cases where index hurts Are Indexes Unnecessary in Exadata