26
Go-Faster Consultancy Ltd . 1 Help! I have far too many extents (What is smon doing?) David Kurtz Go-Faster Consultancy Ltd. david.kurtz@go- faster.co.uk www.go- faster.co.uk

Help! I have far too many extents (What is smon doing?)

  • Upload
    bracha

  • View
    39

  • Download
    0

Embed Size (px)

DESCRIPTION

Help! I have far too many extents (What is smon doing?). David Kurtz Go-Faster Consultancy Ltd. [email protected] www.go-faster.co.uk. Who am I?. DBA Independent Consultant Performance Tuning Oracle/PeopleSoft. What is this all about?. A couple of months I made a mistake - PowerPoint PPT Presentation

Citation preview

Page 1: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 1

Help! I have far too many extents

(What is smon doing?)David KurtzGo-Faster Consultancy Ltd.

[email protected]

www.go-faster.co.uk

Page 2: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 2

Who am I?

• DBA– Independent Consultant– Performance Tuning

• Oracle/PeopleSoft

Page 3: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 3

What is this all about?

• A couple of months I made a mistake– created a table without a storage clause.– due to a late night coding error

• instead of 100’s of rows• actually had 10,000,000’s of rows• 182,000 extents• so we dropped the table• 182,000 free extents

Page 4: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 4

What happened next?

• First time– left smon to get on

with it.– three days

• Second time– we couldn’t wait– we came up with a

more imaginative solution.

– which I will tell you about later

Page 5: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 5

Why couldn’t we wait for smon?

• This occurred on a migration database• Significant amounts of DDL• COALESCE took out, and held, a lock on

the space transaction enqueue• SMON took out ST lock while it was busy.• Certain create statements cause a coalesce.• Only one ST lock allowed.

Page 6: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 6

Why not just drop tablespace?

• It appears that dropping and empty tablespace also coalesces the tablespace.– Trace reveals much of same SQL– Don’t know why

• uet$ already empty• All that is necessary to delete fet$

Page 7: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 7

What did Oracle suggest?

• TRUNCATE TABLE REUSE STORAGE

• ALTER TABLE … DEALLOCATE UNUSED KEEP nnn M;

• ALTER TABLESPACE … COALESCE;

• DROP TABLE …;

Page 8: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 8

Construct a test

• Create a table with 512 8k extents.• Try deallocate and coalesce in n parts.• 1,2,4,8 etc parts• measure time, physical I/O, CPU

Page 9: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 9

Performance of DeallocateDeallocate time -v- Number of Deallocates

0

5

10

15

20

25

30

0 10 20 30 40 50 60 70

Number of Deallocates

Tim

e (s

econ

ds)

Parse

Execute

Fetch

Page 10: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 10

What happens when you…

• Drop Table?• Coalesce Tablespace?• Truncate Table?• Truncate Table Reuse Storage?

• and what does smon do?

Page 11: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 11

How do you find out what is happening?

• SQL_TRACE• Issue the command• TKPROF

– sys = yes– recursive SQL

Page 12: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 12

DROP TABLE

• delete– all catalogue information about table and its

indexes• including 9 tables in C_OBJ# cluster

– UET$ used extent table• insert

– FET$ - free extent table• update TSQ$ - tablespace quota

Page 13: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 13

COALESCE TABLESPACE

• Only 4 SQL statements

• Select from FET$– select file#, block#, ts#, length from fet$

where ts# = :1– select length from fet$ where file#=:1 and

block#=:2 and ts#=:3

Page 14: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 14

COALESCE TABLESPACE

• Delete from FET$, or– delete from fet$

where file#=:1 and block#=:2 and ts#=:3

• Update FET$ set LENGTH#– update fet$ set length=:4

where file#=:1 and block#=:2 and ts# = :3

Page 15: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 15

Is this a problem?

• Is having lots of extents a problem?• Oracle say:

– Not a significant issue during DML operations.– It can be a problem during space management

• TRUNCATE TABLE• DROP TABLE• ALTER TABLESPACE … COALESCE• DROP TABLESPACE

Page 16: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 16

Construct a test

• Create a large tablespace

CREATE TABLESPACE sillyDATAFILE 'e:\ps\db\ora816d\data\silly.dbf' size 800m;

Page 17: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 17

Disable SMON

• Most of the time smon looks for workselect f.file#, f.block#, f.ts#, f.length from fet$ f,

ts$ t where t.ts#=f.ts# and t.dflextpct!=0 and t.bitmapped=0

• Disable SMONALTER TABLESPACE silly DEFAULT STORAGE(PCTINCREASE

0);

Page 18: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 18

Create a badly sized table

CREATE TABLE silly_tab( value VARCHAR2(4000), value2 VARCHAR2(4000)) TABLESPACE sillyPCTFREE 98 PCTUSED 1STORAGE

(INITIAL 8k NEXT 8k PCTINCREASE 0 MAXEXTENTS

UNLIMITED);

Page 19: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 19

Populate the table

INSERT INTO silly_tab SELECT

RPAD(TO_CHAR(TO_DATE(rownum,'j'),'jsp'),4000,'.'), RPAD(TO_CHAR(TO_DATE(rownum,'j'),'jsp'),3000,'.')FROM all_objectsWHERErownum <= 10000

• or create extents with MINEXTENTS

Page 20: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 20

Capture Recursive SQL

• Enable SQL_TRACE– Drop Table– Coalesce Tablespace

– Measure timings from TKPROF

Page 21: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 21

DDL Time -v- Number of Extents

Page 22: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 22

DDL Time -v- Number of Extents

Page 23: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 23

Conclusion

• Time taken to drop and coalesce goes up more than linearly with the number of extents.

• Keep the number of extents manageable– mainly for administrative reasons– but also because coalesce could cause a looking

problem in some scenarios.

Page 24: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 24

Do not try this at home

• This is COMPLETELY UNSUPPORTED• This is how we coalesced our 182,000

extents.– drop object– tablespace now empty– DELETE FROM FET$ WHERE TS# = ...– drop tablespace (quickly)– recreate tablespace

Page 25: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 25

Questions?

Page 26: Help! I have far too many extents  (What is smon doing?)

Go-Faster Consultancy Ltd. 26

Help! I have far too many extents

(What is smon doing?)David KurtzGo-Faster Consultancy Ltd.

[email protected]

www.go-faster.co.uk