Fact-Based Indexing Lothar Flatz Senior Principal Consultant Diso AG - - PowerPoint PPT Presentation

fact based indexing
SMART_READER_LITE
LIVE PREVIEW

Fact-Based Indexing Lothar Flatz Senior Principal Consultant Diso AG - - PowerPoint PPT Presentation

Fact-Based Indexing Lothar Flatz Senior Principal Consultant Diso AG The Swiss Data and Cloud Expert May I introduce myself Indexing for the workload 25 Year Oracle Database experience (starting with Version 5) 15 Years Oracle


slide-1
SLIDE 1

Diso AG – The Swiss Data and Cloud Expert

Lothar Flatz – Senior Principal Consultant

Fact-Based Indexing

slide-2
SLIDE 2

Indexing for the workload

2

May I introduce myself

» 25 Year Oracle Database experience (starting with Version 5) » 15 Years Oracle Employee » Oak Table Member » Ex-Real World Performance Group » Oracle ACE » Signature Project: PVSS (CERN) » US 8103658 B2 patent with Björn Engsig » Senior Principal Consultant at Diso AG

Diso AG – The Swiss Data and Cloud Expert

slide-3
SLIDE 3

Indexing for the workload

3

About Diso AG

» Founded in 1996, 40 employees » Located in Gümligen (Bern), Switzerland » Portfolio:

 Cloud Computing  Software Development  IT Consulting  Managed Services  Project Implementation  System Optimization

Diso AG – The Swiss Data and Cloud Expert

slide-4
SLIDE 4

Indexing for the workload

4

One of Codd’s famous rules: » The system must support an online, inline, relational catalog that is accessible to authorized users by means of their regular query language. That is, users must be able to access the database's structure (catalog) using the same query language that they use to access the database's data «

Diso AG – The Swiss Data and Cloud Expert

Codd, Edgar Frank (14 October 1985), "Is Your DBMS Really Relational?" ComputerWorld

Fact-based Indexing

slide-5
SLIDE 5

Indexing for the workload

5

Fact-based Indexing

The database has valuable information

Diso AG – The Swiss Data and Cloud Expert

slide-6
SLIDE 6

Indexing for the workload

6

Fact-based Indexing

Diso AG – The Swiss Data and Cloud Expert

Raiders of the data dictionary – Indexing for the workload

Let‘s go and find it!

slide-7
SLIDE 7

Indexing for the workload

7

The idea

A consequential coffee break

Diso AG – The Swiss Data and Cloud Expert

“I bet, that at minimum 30% of our indexes are

  • superfluous. I would

prefer to have them all double checked.“

slide-8
SLIDE 8

Indexing for the workload

Some basic rules, please… … no religious discussions!

8

Everybody knows Indexing

Diso AG – The Swiss Data and Cloud Expert

slide-9
SLIDE 9

Indexing for the workload

9 Diso AG – The Swiss Data and Cloud Expert

» Developers define

indexes

» They use a rule of

thumb or their gut feeling

» Quite often they never

see the application under real load

What we have

The usual malaise

slide-10
SLIDE 10

Indexing for the workload

10 Diso AG – The Swiss Data and Cloud Expert

» Very complex data

model

» Never ending

performance trouble

What results

Our case

We want to stop the issues once and for all!

slide-11
SLIDE 11

Indexing for the workload

11

Can we automate this?

» First, while the automated tools reduce the complexity of the physical design process, it is still nontrivial to identify a representative workload that can be used to drive the physical design in its

  • entirety. Second, automated tools do not consider all

factors that impact physical design (e.g., the impact

  • f replication architectures) «

Diso AG – The Swiss Data and Cloud Expert

Bruno, N. and Chaudhuri, S. 2007. Physical design refinement: The ‘merge-reduce’ approach. ACM

  • Trans. Database Syst. 32, 4 (Nov. 2007)

Why work?

slide-12
SLIDE 12

Indexing for the workload

12 Diso AG – The Swiss Data and Cloud Expert

» Developer (software

vendor)

» DBAs » Database consultant

Team up

Who can contribute?

slide-13
SLIDE 13

Indexing for the workload

13 Diso AG – The Swiss Data and Cloud Expert

» Complete » Non-redundant » Minimal » Efficient

Quality

Target

slide-14
SLIDE 14

Indexing for the workload

14 Diso AG – The Swiss Data and Cloud Expert

Patch or build ?

Not incremental, but complete

Drop every index, do it new from scratch

slide-15
SLIDE 15

Indexing for the workload

15 Diso AG – The Swiss Data and Cloud Expert

» Naming convention » Index building rules based on

design principles

» Foreign keys (to index or not to

index)

» Physical attributes (table

spaces)

First Step

Give it Structure

slide-16
SLIDE 16

Indexing for the workload

16 Diso AG – The Swiss Data and Cloud Expert

We need to cover processing

Collect data

» Minimum a

month

» Collect on daily,

weekly and monthly processing

» Various sources

slide-17
SLIDE 17

Indexing for the workload

17 Diso AG – The Swiss Data and Cloud Expert

» Sys.col_usage$ » V$sql_plan » DBA_HIST_SQL_PLAN » V$SQL » Column statistics

» Sys.col_group_usage$ ?

Find the metainformation

Sources

https://blogs.oracle.com/optimizer/entry/ho w_do_i_know_what_extended_statistics_are_n eeded_for_a_given_workload

slide-18
SLIDE 18

Indexing for the workload

18

What is important?

Diso AG – The Swiss Data and Cloud Expert

Column Statistics

COLUMN_NAME EQUALITY_PREDS RANGE_PREDS LIKE_PREDS EQUIJOIN_PREDS

  • --------------- -------------- ----------- ---------- -------------- ------------

KUND_ID 129 0 0 165 KUND_STATUS 165 0 0 0 KUND_CLASSID 0 0 0 154 KUND_MANDANT 107 1 0 10 KUND_TYPE 104 0 0 0 KUND_FAMILIENNR 90 0 0 0 KUND_GEBURTSTAG 84 0 0 0 KUND_POTFAMILIENNR 84 0 0 0 KUND_VERSICHERTENNR 67 0 0 1

slide-19
SLIDE 19

Indexing for the workload

19

What is selective?

Diso AG – The Swiss Data and Cloud Expert

Column Statistics

Column Distinct Name Values Density NUM_BUCKETS

  • ----------------------------- -------------- ------- -----------

KUND_VERSICHERTENNR 3,191,680 0 1 KUND_GPANR 2,683,264 0 1 KUND_FAMILIENNR 1,265,369 0 1 KUND_BEZEICHNER 1,228,595 0 200 KUND_STRASSE 449,653 0 198 KUND_POTFAMILIENNR 197,732 0 200 KUND_NAME 157,774 0 199 KUND_ROOTID 68,922 0 1 KUND_VORNAME 66,494 0 195 KUND_GEBURTSTAG 36,520 0 200 KUND_KVNR 10,227 0 116 KUND_ORT 8,964 0 174 KUND_PLZ 4,242 0 200 KUND_MANDANT 28 0 27 KUND_TYPE 6 0 5

slide-20
SLIDE 20

Indexing for the workload

20

Search combinations

Diso AG – The Swiss Data and Cloud Expert

Collected from v$sql_plan

COL_STR Number Queries EXECUTIONS

  • --------------------------------------------------------------------- --------------- ----------

KUND_ID 84 3408270 KUND_TYPE,NLS_UPPER(KUND_BEZEICHNER),NLS_UPPER(KUND_KVNR),NLS_UPPER(KO 1 372568 NT_VERSICHERTENNR) KUND_FAMILIENNR,KUND_ID,KUND_MANDANT 17 175198 KUND_FAMILIENNR,KUND_ID,KUND_MANDANT,KUND_POTFAMILIENNR 17 27890 KUND_ID,KUND_POTFAMILIENNR 2 24946 KUND_TYPE,NLS_UPPER(KUND_NAME),NLS_UPPER(KUND_VORNAME) 1 11920 KUND_FAMILIENNR 2 11879 KUND_ID,KUND_TYPE 1 10029 KUND_FAMILIENNR,KUND_POTFAMILIENNR 2 6654 KUND_GEBURTSTAG,KUND_TYPE,NLS_UPPER(KUND_PLZ) 1 3862 KUND_TYPE,KUND_VERSICHERTENNR 2 2936 KUND_POTFAMILIENNR 2 368

slide-21
SLIDE 21

Indexing for the workload

21 Diso AG – The Swiss Data and Cloud Expert

What was a feeling

All information is on the table… … we just have to organize it

slide-22
SLIDE 22

Indexing for the workload

22 Diso AG – The Swiss Data and Cloud Expert

Must become words

Brain block, got stuck?

Your right brain tries to say the color while your left brain insist on reading the word.

Look at the chart and say the COLOR and not the word.

slide-23
SLIDE 23

Indexing for the workload

23 Diso AG – The Swiss Data and Cloud Expert

Words blocking the flow

How do I get out of it? Let go your conscious self and …. act on instinct.

slide-24
SLIDE 24

Indexing for the workload

24

Order and conquer

Diso AG – The Swiss Data and Cloud Expert

There it is …

COLUMN_NAME EQUALITY_PREDS RANGE_PREDS LIKE_PREDS EQUIJOIN_PREDS

  • --------------- -------------- ----------- ---------- -------------- ------------

KUND_ID 129 0 0 165 KUND_STATUS 165 0 0 0 KUND_CLASSID 0 0 0 154 KUND_MANDANT 107 1 0 10 KUND_TYPE 104 0 0 0 KUND_FAMILIENNR 90 0 0 0 KUND_GEBURTSTAG 84 0 0 0 KUND_POTFAMILIENNR 84 0 0 0 KUND_VERSICHERTENNR 67 0 0 1

Rank

  • 1

2 3 4 5 6 7

KUND_FAMILIENNR,KUND_ID,KUND_MANDANT

Al All you need i l you need is so s some me repeat epeating ing st stru ruct ctur ure. e. Arrange t Arrange the col he columns umns su such ch th that at reus euse i e is mos s most t li likely kely

KUND_ID,KUND_MANDANT, KUND_FAMILIENNR

slide-25
SLIDE 25

Indexing for the workload

25

Reduce

Diso AG – The Swiss Data and Cloud Expert

Eliminate superfluous indexes

{last name, first name, Age} {last name, first name} {last name}

slide-26
SLIDE 26

Indexing for the workload

26

Merge

Diso AG – The Swiss Data and Cloud Expert

Combine indexes when possible

{last name, first name, City} {last name, first name, ZIP} {last name, first name, City, ZIP}

Compare: Jonathan Lewis's Index usage

slide-27
SLIDE 27

Indexing for the workload

27 Diso AG – The Swiss Data and Cloud Expert

» Generate create index

scripts

» Drop all existing

indexes

» Build indexing from

scratch

Indexing for the Workload

Implement

slide-28
SLIDE 28

Indexing for the workload

28 Diso AG – The Swiss Data and Cloud Expert

» Loadtests (Batch) » RAT

Safty first

Test

slide-29
SLIDE 29

Indexing for the workload

29 Diso AG – The Swiss Data and Cloud Expert

» Missing indexes » Improvable

indexes

» Manual patching

Wrap up

Close remaining gaps

slide-30
SLIDE 30

Indexing for the workload

30 Diso AG – The Swiss Data and Cloud Expert

» Less index space (30%) » Faster batch programs » Higher plan stability » 90% less memory

according to software vendor recommendation

Indexing for the Workload

Results

slide-31
SLIDE 31

Indexing for the workload

31 Diso AG – The Swiss Data and Cloud Expert

» The issues did not

come back

» They were resolved

  • nce and for all

Finally

Done !

slide-32
SLIDE 32

Indexing for the workload

32

7 years later

» The DBAs at (company where indexing was changed) are looking so relaxed. I want that too! «

Diso AG – The Swiss Data and Cloud Expert

A DBA group leader running that same software visiting the site

Review

slide-33
SLIDE 33

Indexing for the workload

33

Conclusions

No Fairy Tales:

There are no alternative to hard facts

Diso AG – The Swiss Data and Cloud Expert

slide-34
SLIDE 34

Do not hesitate to contact me for more information.

Thank you very much for your attention!

34

Lothar Flatz

Diso AG Morgenstrasse 1 3073 Gümligen / CH Phone +41 31 958 90 90 info@diso.ch www.diso.ch

Diso AG – The Swiss Data and Cloud Expert