35
Should I Drop Indexes in Exadata? Arup Nanda Priceline (a Booking Holdings Company)

Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Should I Drop Indexes inExadata?

Arup NandaPriceline

(a Booking Holdings Company)

Page 2: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

DisclaimerIf 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.

Should I Drop Indexes in Exadata2

Page 3: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Should I Drop Indexes in Exadata3

Quotes

Why? Because there is a storage index.“”

Drop all the indexes and reclaim space.“”

You don’t need indexes on Exadata.“”

Page 4: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

3 Questions for “Best Practices”

Should I Drop Indexes in Exadata4

1. Why it is better than the rest?

2. What happens if it is notfollowed?

3. When are they not applicable?

Page 5: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Should I Drop Indexes in Exadata5

Storage Index

Page 6: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Instances and Databases

6

Storage

datafile1datafile2

SELECT NAMEFROM CUSTOMERSWHERE STATUS ='ANGRY'

Instance

Combination of •Memory Areas•Background Processes

Should I Drop Indexes in Exadata

Page 7: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Query Processing

7Storage

datafile1datafile2

SELECT NAMEFROM CUSTOMERSWHERE STATUS ='ANGRY'

Database Block

JILL

Should I Drop Indexes in Exadata

Page 8: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Should I Drop Indexes in Exadata8

Index

Table

Page 9: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Components for Performance

9

CPU

Memory

Network

I/O Controller

Disk

Less I/O = better performance

Should I Drop Indexes in Exadata

Page 10: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata

Page 11: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

11

CPU

Memory

Network

I/O Controller

Disk

iDB

Should I Drop Indexes in Exadata

Page 12: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Should I Drop Indexes in Exadata12

Disk1 Disk2 Disk3

iDB

Page 13: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

13

Disk4

MIN = 3

MAX = 5

MIN = 4

MAX = 5

MIN = 3

MAX = 5

MIN = 1

MAX = 3

Disk1 Disk2 Disk3

Storage Index

SELECT …FROM TABLEWHERE COL1 = 2

Should I Drop Indexes in Exadata

Page 14: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata14

Page 15: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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’)

15Should I Drop Indexes in Exadata

OutputSTAT_NAME STAT_VALUE---------- ----------SI Savings 5120.45Smart Scan 1034.00

Page 16: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Offloading and Smart Scan

OffloadingProcessing to storage cells

Smart ScanReduction in I/O

Should I Drop Indexes in Exadata16

Page 17: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Offloading• Column Projection

select cust_id, sale_amtfrom sales

• Predicate Filteringwhere status = ‘ANGRY’

• Function Offloadingselect min(sale_amt)

• Virtual Columns

Should I Drop Indexes in Exadata17

Page 18: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata18

Page 19: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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.

19Should I Drop Indexes in Exadata

Page 20: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Impact of Data Distribution

Should I Drop Indexes in Exadata20

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

Page 21: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

8 Columns

Should I Drop Indexes in Exadata21

C1C2C3C4C5C6C7C8

C2C3C4C5C6C7C8C9

C3C4C5C6C7C8C9C10

TableT1

Page 22: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

No Predicate• Aggregations

select sum(sale_amt) from sales

• Sortingselect ... from salesorder by sale_amt;

Should I Drop Indexes in Exadata22

Index on SALE_AMT

Page 23: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Function Based Indexes• Traditional Indexes can’t work

select … from saleswhere to_char(sale_dt,’YY’) = ‘13’

• Function Based Indexes help• SI indexes will not be useful

Should I Drop Indexes in Exadata23

Page 24: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

IOTs• Index Organized Tables• PK-based rows• Secondary Indexes built

on the other columns

Should I Drop Indexes in Exadata24

PK

Index

Index

Page 25: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Clustered Tables

Should I Drop Indexes in Exadata25

Page 26: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Exclusion for SIs• Not for non-equality select sale_amtfrom saleswhere status != ‘SHIPPED’

• No Wildcardsselect sale_amtfrom saleswhere city like ‘NEW YORK%’

Should I Drop Indexes in Exadata26

Page 27: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata27

Page 28: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata28

Page 29: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata29

Page 30: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Flash Cache

30

Storage

datafile1datafile2

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.

Should I Drop Indexes in Exadata

alter table person storage (cell_flash_cachekeep)

Page 31: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata31

Page 32: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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.

Should I Drop Indexes in Exadata32

Page 33: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Disable

• Two parameters– Could be session level

• To disable offloadingcell_offload_processing = false;

• To disable storage indexes alone_kcfis_storageidx_disabled = true;

Should I Drop Indexes in Exadata33

Page 34: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

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

Should I Drop Indexes in Exadata34

Page 35: Are Indexes Unnecessary In ExadataShould I Drop Indexes in Exadata 3 Quotes Why?Because there is a storage index. “ ” Drop all the indexes “ and reclaim space. ” You don’t

Thank You!Blog: arup.blogspot.com | Twitter: arupnanda com | Facebook.com/ArupKNanda

Download Scripts: proligence.com/pres/sangam18

Should I Drop Indexes in Exadata35