Presentation is loading. Please wait.

Presentation is loading. Please wait.

13 Copyright © 2006, Oracle. All rights reserved. Tuning PGA and Temporary Space.

Similar presentations


Presentation on theme: "13 Copyright © 2006, Oracle. All rights reserved. Tuning PGA and Temporary Space."— Presentation transcript:

1 13 Copyright © 2006, Oracle. All rights reserved. Tuning PGA and Temporary Space

2 Copyright © 2006, Oracle. All rights reserved. 13-2 Objectives After completing this lesson, you should be able to do the following: Diagnose PGA memory issues Size the PGA memory Diagnose temporary space issues Specify temporary tablespace parameters for efficient operation

3 Copyright © 2006, Oracle. All rights reserved. 13-3 SQL Memory Usage Memory-intensive SQL operators: –Sort-based (sort, group-by, rollup, window,...) –Hash-join –Bitmap operators (merge and inversion) Concept of work area: –Memory allocated by a memory-intensive operator to process its input data Performance impact of memory: –Optimal: Input data fits into the work area (cache). –One-pass: Perform one extra pass over input data. –Multi-pass: Perform several extra passes over input data.

4 Copyright © 2006, Oracle. All rights reserved. 13-4 Performance Impact Response Time Memory.. 1-passoptimalM-pass Sort Response Time.. Hash-Join M 1-pass M optimal M 1-pass M optimal 1-passoptimalM-pass Memory

5 Copyright © 2006, Oracle. All rights reserved. 13-5 Automatic PGA Memory Dynamically adapts the SQL memory allocation based on: –PGA memory available –SQL operator needs –System workload Improves manageability: –No need to set *_AREA_SIZE parameters –DBA sets a memory target: PGA_AGGREGATE_TARGET Improves performance: –PGA memory is really returned to the OS. –Memory is allocated to the operation to maximize throughput. –Maximize overall memory utilization by dynamically adapting memory with workload variation. –Operation adapts its memory usage during the execution.

6 Copyright © 2006, Oracle. All rights reserved. 13-6 SQL Memory Manager...... HJ GB HJ WP 1 Local SMM HJ GB WP 5 Server-1 Server-n SGA Global memory bound Global SMM (CKPT) Aggregate PGA auto-target Memory Bound Computation every 3s WP 2 Local SMM WP 3 WP 4 V$SQL_WORKAREA_ACTIVE V$SQL_WORKAREA PGA Memory Usage Statistics PGA_AGGREGATE_TARGET V$PROCESS V$PROCESS_MEMORY V$PGASTAT WP 5 WP 2 WP 1 V$PGASTAT Auto-Target Computation WP 3 WP 4

7 Copyright © 2006, Oracle. All rights reserved. 13-7 Notes only page

8 Copyright © 2006, Oracle. All rights reserved. 13-8 Configuring Automatic PGA Memory PGA_AGGREGATE_TARGET : –Specifies the target aggregate amount of PGA memory available to the instance –Can be dynamically modified at the instance level –Examples: 100,000 KB; 2,500 MB; 50 GB –Default value: 10 MB or 20% of the size of the SGA, whichever is greater WORKAREA_SIZE_POLICY : –Optional –Can be dynamically modified at the instance or session level –Allows you to fall back to static SQL memory management for a particular session

9 Copyright © 2006, Oracle. All rights reserved. 13-9 Setting PGA_AGGREGATE_TARGET Initially Leave 20% of the available memory to other applications. Leave 80% of memory to the Oracle instance. For OLTP: For DSS: PGA_AGGREGATE_TARGET=(total_mem*80%)*20% PGA_AGGREGATE_TARGET=(total_mem*80%)*50%

10 Copyright © 2006, Oracle. All rights reserved. 13-10 Monitoring SQL Memory Usage V$SQL_WORKAREA_ACTIVE V$SQL_WORKAREA V$PGASTAT V$SQL_PLAN V$SQL V$SQL_WORKAREA_HISTOGRAMS V$PROCESS_MEMORY V$SYSSTAT V$TEMPSEG_USAGE

11 Copyright © 2006, Oracle. All rights reserved. 13-11 Notes only page

12 Copyright © 2006, Oracle. All rights reserved. 13-12 Monitoring SQL Memory Usage: Examples SELECT sql_text, sum(onepass_executions) onepass_cnt, sum(multipasses_executions) mpass_cnt FROM V$SQL s, V$SQL_WORKAREA wa WHERE s.address = wa.address GROUP BY sql_text HAVING sum(onepass_executions+multipasses_executions)>0; SELECT TO_NUMBER(DECODE(sid, 65535, NULL, sid)) sid, operation_type OPERATION, TRUNC(expected_size/1024) ESIZE, TRUNC(actual_mem_used/1024) MEM, TRUNC(max_mem_used/1024) MAXMEM, number_passes PASS, TRUNC(tempseg_size/1024) TSIZE FROM V$SQL_WORKAREA_ACTIVE ORDER BY 1,2; 1 2

13 Copyright © 2006, Oracle. All rights reserved. 13-13 Tuning SQL Memory Usage Determine the best PGA_AGGREGATE_TARGET value by using: – V$PGA_TARGET_ADVICE – V$PGA_TARGET_ADVICE_HISTOGRAM Monitor AWR reports/Statspack reports for: – direct path read temp – direct path write temp

14 Copyright © 2006, Oracle. All rights reserved. 13-14 PGA Target Advice Statistics V$PGA_TARGET_ADVICE predicts how cache hit percentages shown in V$PGASTAT evolve. STATISTICS_LEVEL must be set to at least TYPICAL. V$PGA_TARGET_ADVICE 13%25%50%75% 100%120%140%160%180%200%300%400% PGA_TARGET_FACTOR ESTD_PGA_CACHE_HIT_PERCENTAGE Current value Over allocation zone Good value ESTD_OVERALLOC_COUNT 0 10 20 30 40 50 60 70 80 90 100

15 Copyright © 2006, Oracle. All rights reserved. 13-15 PGA Target Advice Histograms V$PGA_TARGET_ADVICE_HISTOGRAM predicts how histograms shown in V$SQL_WORKAREA_HISTOGRAM evolve. STATISTICS_LEVEL must be set to at least TYPICAL.

16 Copyright © 2006, Oracle. All rights reserved. 13-16 Automatic PGA and Enterprise Manager

17 Copyright © 2006, Oracle. All rights reserved. 13-17 Automatic PGA and AWR Reports

18 Copyright © 2006, Oracle. All rights reserved. 13-18 Temporary Tablespace Management: Overview Temporary data generated by a database include: –Bitmap merges –Hash-join –Bitmap index creation –Sort –Temporary LOBs –Global temporary tables Data persists for the duration of a transaction or session. High concurrency of the space management operation is critical. Media and instance recovery is not required.

19 Copyright © 2006, Oracle. All rights reserved. 13-19 Temporary Tablespace: Best Practice Using locally managed temporary tablespace: Allows high-concurrency space management –At steady state, all space metadata is cached in SGA. –Operations are serialized by the SGA latch. Allows faster writes to temp files. Redo generated on temporary blocks is not written to disk. Makes READ ONLY databases possible

20 Copyright © 2006, Oracle. All rights reserved. 13-20 Configuring Temporary Tablespace Locally managed temporary tablespaces are uniform-extent tablespaces. 1 MB to 10 MB extent size: –For DSS, OLAP applications involving huge work areas –Large temporary LOBs are predominant. 64 KB or multiple less than 1 MB: –Small global temporary tables are predominant. –OLTP Use V$TEMPSEG_USAGE to monitor space usage and workload distribution.

21 Copyright © 2006, Oracle. All rights reserved. 13-21 Notes only page

22 Copyright © 2006, Oracle. All rights reserved. 13-22 Temporary Tablespace Group: Overview Groups multiple temporary tablespaces Characteristics: –At least one temporary tablespace –Same namespace as tablespaces –Created implicitly on first assignment –No explicit deletion Default tablespace EXAMPLE … Default temporary tablespace group TEMP Tablespace TEMP1 Tablespace TEMPn

23 Copyright © 2006, Oracle. All rights reserved. 13-23 Temporary Tablespace Group: Benefits Enables a user to use multiple temporary tablespaces: Same user in multiple sessions One particular parallel operation Temporary tablespace group TEMP Tablespace TEMP1 Tablespace TEMP2 Tablespace TEMP3 Serial Parallel HR

24 Copyright © 2006, Oracle. All rights reserved. 13-24 Creating Temporary Tablespace Groups

25 Copyright © 2006, Oracle. All rights reserved. 13-25 Maintaining Temporary Tablespace Groups

26 Copyright © 2006, Oracle. All rights reserved. 13-26 Data Dictionary Changes SELECT group_name, tablespace_name FROM DBA_TABLESPACE_GROUPS;

27 Copyright © 2006, Oracle. All rights reserved. 13-27 Monitoring Temporary Tablespace Use V$TEMPSEG_USAGE to monitor space usage and workload distribution: Use V$SORT_SEGMENT to determine space usage percentage: SELECT session_num, username, segtype, blocks, tablespace FROM V$TEMPSEG_USAGE; SELECT (s.tot_used_blocks/f.total_blocks)*100 as pctused FROM (SELECT SUM(used_blocks) tot_used_blocks FROM V$SORT_SEGMENT WHERE tablespace_name='TEMP') s, (SELECT SUM(blocks) total_blocks FROM DBA_TEMP_FILES WHERE tablespace_name='TEMP') f;

28 Copyright © 2006, Oracle. All rights reserved. 13-28 Practice Overview: Tune PGA Memory This practice covers the following topics: Enable Automatic PGA Memory Tune PGA_AGGREGATE_TARGET Tune Temporary Tablespace Performance

29 Copyright © 2006, Oracle. All rights reserved. 13-29 Summary In this lesson, you should have learned how to: Diagnose PGA memory issues Size the PGA memory Diagnose temporary space issues Specify temporary tablespace parameters for efficient operation

30 Copyright © 2006, Oracle. All rights reserved. 13-30


Download ppt "13 Copyright © 2006, Oracle. All rights reserved. Tuning PGA and Temporary Space."

Similar presentations


Ads by Google