Upload
arup-nanda
View
582
Download
1
Tags:
Embed Size (px)
DESCRIPTION
You heard it - drop indexes in Exadata. But should you? Learn why that is true in some cases and, more important, when it is not.
Citation preview
Are Indexes Unnecessary in Exadata?
Arup NandaLongtime Oracle DBA
(and now DMA)
Are Indexes Unnecessary in Exadata2Arup Nanda
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 Exadata3Arup Nanda
Quotes
Why? Because there is a storage index.“”
Drop all the indexes and reclaim space.“
”
You don’t need indexes on Exadata.“
”
Are Indexes Unnecessary in Exadata4Arup Nanda
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 Exadata5Arup Nanda
Storage Index
Are Indexes Unnecessary in Exadata
Arup Nanda
Instances and Databases
6
Storage
Server
PMON
DBWR
datafile1datafile2
Buffer cache
SELECT NAMEFROM CUSTOMERSWHERE STATUS ='ANGRY'
Instance
Combination of •Memory Areas•Background Processes
Are Indexes Unnecessary in Exadata
Arup Nanda
Query Processing
7Storage
Server
PMON
DBWR
datafile1datafile2
Buffer cache
SELECT NAMEFROM CUSTOMERSWHERE STATUS ='ANGRY'
Database Block
CUSTID NAME STATUS
1 JOHN HAPPY
2 JILL ANGRY
3 JOE HAPPY
500 JIM HAPPY
JILL
Are Indexes Unnecessary in Exadata8Arup Nanda
CUSTID NAME STATUS
1 JOHN HAPPY
2 JILL ANGRY
3 JOE HAPPY
500 JIM HAPPY
ANGRY ANGRY
CUSTID NAME STATUS
11 JOHN HAPPY
2 JILL ANGRY
3 JOE HAPPY
500 JIM HAPPY
CUSTID NAME STATUS
1 JOHN HAPPY
2 JILL ANGRY
3 JOE HAPPY
500 JIM HAPPY
CUSTID NAME STATUS
111 JOHN HAPPY
211 JILL HAPPY
332 JOE HAPPY
5010 JIM HAPPY
Index
Table
Block 11
Block 42
Block 31
Block 24
Are Indexes Unnecessary in Exadata
Arup Nanda
Components for Performance
9
CPU
Memory
Network
I/O Controller
Disk
Less I/O = better performance
Are Indexes Unnecessary in Exadata
Arup Nanda
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
10
SELECT NAMEFROM CUSTOMERSWHERE STATUS ='ANGRY'
CPU
Memory
Network
I/O Controller
Disk
Filtering should be
Applied Here
Are Indexes Unnecessary in Exadata
Arup Nanda 11
CPU
Memory
Network
I/O Controller
Disk
Get NAME
… STATUS = ‘ANGRY’
iDB
Are Indexes Unnecessary in Exadata
Arup Nanda 12
Disk1
Cell Server
Disk2 Disk3
ESS
iDB
Arup Nanda 13
1 2 3 4
Disk4
MIN = 3
MAX = 5
MIN = 4
MAX = 5
MIN = 3
MAX = 5
MIN = 1
MAX = 3
Disk1
Cell Server
Disk2 Disk3
ESS
Storage Index
SELECT …FROM TABLEWHERE COL1 = 2
Are Indexes Unnecessary in Exadata
Are Indexes Unnecessary in Exadata14Arup Nanda
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 Exadata15Arup Nanda
Checking Storage Index Useselect name, value/1024/1024 as stat_valuefrom v$mystat s, v$statname nwhere 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’)
OutputSTAT_NAME STAT_VALUE---------- ----------SI Savings 5120.45Smart Scan 1034.00
Are Indexes Unnecessary in Exadata16Arup Nanda
Offloading and Smart Scan
OffloadingProcessing to storage cells
Smart ScanReduction in I/O
Are Indexes Unnecessary in Exadata17Arup Nanda
Offloading
• Column Projectionselect cust_id, sale_amtfrom sales
• Predicate Filteringwhere status = ‘ANGRY’
• Function Offloadingselect min(sale_amt)
• Virtual Columns
Are Indexes Unnecessary in Exadata18Arup Nanda
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 Exadata19Arup Nanda
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 Exadata20Arup Nanda
Impact of Data Distribution
1 2 3 4
Disk4
MIN = 3
MAX = 5
MIN = 4
MAX = 5
MIN = 3
MAX = 5
MIN = 1
MAX = 2
MIN = 1
MAX = 5
MIN = 1
MAX = 5
MIN = 1
MAX = 5
MIN = 1
MAX = 5
SELECT …FROM TABLEWHERE COL1 = 2
Are Indexes Unnecessary in Exadata21Arup Nanda
8 Columns
1 2 3
C1C2C3C4C5C6C7C8
C2C3C4C5C6C7C8C9
C3C4C5C6C7C8C9C10
Table T1
Are Indexes Unnecessary in Exadata22Arup Nanda
No Predicate
• Aggregationsselect sum(sale_amt) from sales
• Sortingselect ... from salesorder by sale_amt;
Index on SALE_AMT
Are Indexes Unnecessary in Exadata23Arup Nanda
Function Based Indexes
• Traditional Indexes can’t workselect … from saleswhere to_char(sale_dt,’YY’) = ‘13’
• Function Based Indexes help• SI indexes will not be useful
Are Indexes Unnecessary in Exadata24Arup Nanda
IOTs
• Index Organized Tables
• PK-based rows• Secondary Indexes
built on the other columns
CUSTID NAME STATUS
1 JOHN HAPPY
2 JILL ANGRY
3 JOE HAPPY
500 JIM HAPPY
PK
Index
Index
Are Indexes Unnecessary in Exadata25Arup Nanda
Clustered Tables
CUSTID NAME STATUS
1 JOHN HAPPY
2 JILL ANGRY
3 JOE HAPPY
500 JIM HAPPY
CUSTOMERS
SmallvilleElmSt 234
Anytown Main St 123
ADDR3ADDR2 ADRR1
ADDRESSES
Are Indexes Unnecessary in Exadata26Arup Nanda
Exclusion for SIs
• Not for non-equality select sale_amt from saleswhere status != ‘SHIPPED’
• No Wildcardsselect sale_amtfrom saleswhere city like ‘NEW YORK%’
Are Indexes Unnecessary in Exadata27Arup Nanda
Virtual Columns
• Examplealter 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 Exadata28Arup Nanda
Indexes on Small Tables
• Small table– Parameter _small_table_threshold
• Indexes still help small tablehttp://richardfoote.wordpress.com/2009/04/16/indexes-on-small-tables-part-i-one-of-the-few/
– Less latching
Are Indexes Unnecessary in Exadata29Arup Nanda
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
Arup Nanda
Flash Cache
30
Storage
Server
PMON
DBWR
datafile1datafile2
Buffer cache
Flash
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)
Are Indexes Unnecessary in Exadata31Arup Nanda
Flash Trick for Indexes
• Pin Oft-Used Objects in FlashSQL> alter index in_t2 storage (cell_flash_cache keep);
• Check flashCellCLI> list flashcachecontent attributes –> cachedKeepSize, cachedSize, hitCount, -> hoursToExpiration, missCount -> where objectnumber = 382380;
• Or, partitions
Are Indexes Unnecessary in Exadata32Arup Nanda
Drop the Index?
• Make the indexes invisibleSQL> 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 Exadata33Arup Nanda
Disable
• Two parameters– Could be session level
• To disable offloadingcell_offload_processing = false;
• To disable storage indexes alone_kcfis_storageidx_disabled = true;
Are Indexes Unnecessary in Exadata34Arup Nanda
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 Exadata35Arup Nanda
Thank You!Blog: arup.blogspot.com | Twitter: arupnanda