tuning tips for developers -...

51
www.sagecomputing.com.au [email protected] Tuning Tips for Developers Penny Cookson SAGE Computing Services SAGE Computing Services Customised Oracle Training Workshops and Consulting

Upload: vuongthuan

Post on 28-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

www.sagecomputing.com.au

[email protected]

Tuning Tips for Developers

Penny Cookson SAGE Computing Services

SAGE Computing Services

Customised Oracle Training Workshops and Consulting

SAGE Computing Services

Customised Oracle Training Workshops and Consulting

Penny Cookson

Managing Director and Principal Consultant

Working with Oracle products since 1987

Oracle Magazine Educator of the Year 2004

www.sagecomputing.com.au

[email protected]

Explain Plan

BEGINdbms_stats.gather_table_stats(ownname=>'AUSOUG', tabname=>'BOOKINGS_LARGE', cascade=>TRUE, method_opt => 'FOR ALL COLUMNS SIZE 1 FOR COLUMNS SIZE 254 RESOURCE_CODE, STATUS ',no_invalidate=>FALSE);END;/

Explain Plan

Is seriously flawed

SQL*Developer

Worksheets limit the rows

What access path did it really take?

DBMS_XPLAN.DISPLAY_CURSOR

You need

SELECT_CATALOG_ROLE

Is there an index?

Is the column selective enough?

Do we have statistics?

Do we have skewed data?

Do we have a histogram?

Have the values changed since

we gathered it?

You need the DBA to install this initially and give you the SQLT_USER_ROLE(ADVISOR and SELECT_CATALOG_ROLE)

SQLTXPLAIN documentation

SQL>@runstuff22SQL>@sqltxtract 458phj6d932uu Manager1

Is there an index?

Is the column selective enough?

Do we have statistics?

Do we have skewed data?

Do we have a histogram?

Have the values changed since

we gathered it?

What is the effect of Bind

Variables?

N.B. This example was created before I reran the statistics

Examplesqlt_s94545_xtract_458phj6d932uu

Works best with Performance Pack and DBA privs but you can run as a normal user with SELECT_CATALOG_ROLE

From Oracle

You need the DBA to install this initially and give you the SQLT_USER_ROLE(ADVISOR and SELECT_CATALOG_ROLE)

sqltxtract 458phj6d932uu Manager1

You need the SQLTXPLAIN password

Does not create any objects

DBA only needs to give you SELECT_CATALOG_ROLE

From Oracle

SQL> @runstuff10SQL>@SQLHC T aahd7nzrkf09y

Examplesqlhc_20150813_172633_aahd7nzrkf09y

SQLD360

Nothing installed

Don’t need Oracle account

Analyses AWR/ASH

You can run it with SELECT_CATALOG_ROLE

More information if you have Performance Packs

SQL> @runstuff22SQL>@SQLD360 T 458phj6d932uu

Examplesqld360_dba

Examplesqld360_user

sqld360_user_N

Exampleedb360_sample

SELECT a.buffer_gets, a.executions,TRUNC(a.buffer_gets / nullif(a.executions,0)) getsper,a.sql_fulltext

FROM v$sqlstats aWHERE a. buffer_gets / nullif(a.executions,0) > :readsORDER BY a.buffer_gets / nullif(a.executions,0) DESC;

What statement is causing the problem

What to ask for:DEV/TEST: SQLTEXPLAIN installed

SQLT_USER_ROLE grantedSQLTXPLAIN passwordWhich packs are licensed?

Or worst caseSELECT_CATALOG_ROLE

PROD: User with CREATE SESSION andSELECT_CATALOG_ROLEWhich packs are licensed?

For Production Support/Developers who are expected to

assist with production performance problems

What to use:Explain Plan: Can be misleading

dbms_xplan.display_cursor: for what it really did

SQLD360: for pretty much everything about the one statement -no objects required (Accenture Enkitec Group)

v$ tables: v$sqlstats, v$sql_plan, v$sqlplan_statistics

SQLTXPLAIN: for pretty much everything about the one statement if you can get access and the DBA will create the objects (Oracle)

SQLHC: if your DBA won’t create the objects for SQLTXPLAIN (Oracle)

eDB360: for everything about everything (Accenture Enkitec Group)

Is there an index?

Is the column selective enough?

Do we have statistics?

Do we have skewed data?

Do we have a histogram?

Have the values changed since

we gathered it?

What is the effect of Bind

Variables?

What is the effect of the Optimisation Environment?

Do we have extended statistics?

Are they the right indexes

(order)?

Are they collected correctly

(sample size)?

Have I just written lousy code?

www.sagecomputing.com.au

[email protected]

Questions?

Penny Cookson SAGE Computing Services

SAGE Computing Services

Customised Oracle Training Workshops and Consulting