Evidence of Sort Sizes in An Oracle10g Database
Evidence of Sort Sizes in An Oracle10g Database
Michael R. Ault
This test was constructed as a repeatable test case to show that the principles set forth in
Don Burleson’s article Undocumented secrets for super-sizing your PGA are correct in
most of the cases that I see as an Oracle tuning consultant.
.
Test Plan:
Test System
The test is being accomplished utilizing a 3.0 gigahertz hyper threading P4 based system
running the RedHat 3 kernel and utilizing the 10.1.0.3 release of Oracle. The test system
runs against an 8 disk Nstore disk array that is in a RAID1 configuration with 1 128K
stripe width; all disks participate in the stripe. The total available capacity is 120
gigabytes of external storage with two additional internal drives each with 110 gigabytes
of formatted capacity. The internal drives are used for the operating system and programs
as well as swap area. The external drive array is utilized strictly for Oracle data. ASM is
not being utilized.
Test Table
The test table consists of the columns shown in Figure 1 and contains simulated health
record related data.
desc test_pga
Name Null? Type
----------------------------------------- -------- ----------------------------
NAME VARCHAR2(128)
CODE1 VARCHAR2(4)
CODE2 VARCHAR2(4)
DISTRICT_NAME VARCHAR2(30)
MONTH VARCHAR2(6)
CODE3 VARCHAR2(9)
CODE_3_DESC VARCHAR2(30)
FIRST_DATE DATE
SEC_DATE DATE
COUNT1 NUMBER
COUNT2 NUMBER
COUNT3 NUMBER
The table size and row count data are shown in Figure 2:
SQL> select table_name,num_rows,(blocks*8192)/(1024*1024) meg, avg_row_len from
user_tables where table_name='TEST_PGA';
With a size of over 624 megabytes this table should provide maximum sort segment
sizing with the test SQL statement shown in Figure 3 for both serial and parallel sorts.
SQL for serial tests:
The degree of parallel in the PARALLEL hint in the test SQL will be varied between 2
and 7 during the test.
Figure 4 shows the validation of the Oracle version and options used during the test.
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Prod
PL/SQL Release 10.1.0.3.0 - Production
CORE 10.1.0.3.0 Production
TNS for Linux: Version 10.1.0.3.0 - Production
NLSRTL Version 10.1.0.3.0 – Production
Figure 5: OS Validation
Appendix A contains the full list of documented and undocumented parameters form the
start of the test.
Figure 6 shows the baseline startup statistics from the test system.
SQL>
ORACLE instance started.
30 rows selected.
The test results will be captured by procedure and placed into the test_results table:
desc test_results
Name Null? Type
----------------------------------------- -------- -------------------
SID NUMBER
WORK_AREA_SIZE NUMBER
EXPECTED_SIZE NUMBER
ACTUAL_MEM_USED NUMBER
MAX_MEM_USED NUMBER
TEMPSEG_SIZE NUMBER
NOW VARCHAR2(12)
The following procedure will be used to populate the test results table:
The procedure selects results into the test results table every second while it still sees
sorts occurring. This is a test environment dedicated to this test so no other users will be
present on the system. In a busy system the procedure would have to be modified to
allow for the proper SIDS to be captured. The TEST_RESULTS table will be truncated
after each test run (the results will be moved to an excel spreadsheet for analysis).
This concludes the documentation of the test platform and start conditions for the test.
Results
The results show close agreement with the predicted behavior. The two sets of tests
involved serial sort behavior and parallel sort behavior.
250
200
Megabytes
150
100
50
0
1g 4g 4g 400 pms
Predicted
PGA_AGGREGATE_TARGET
Actual
The data used to compile chart one is shown in Table 1 and was derived by taking the
maximum sort memory utilized from the results for a specific test. All serial test results
are in Appendix B.
While we didn’t achieve the full 200 megabytes expected, we still increased available
sort size by a factor of 3.8, very close to the predicted factor of 4.
180
160
Memory (Meg)
140
120
100
80
60
40
20
0
DOP DOP DOP DOP DOP DOP
2 3 4 5 6 7
Degree of Parallel Predicted Size
Actual Size
Chart 2: Actual Verses Predicted Sort Size for Various DOP Settings
Notice that a DOP of 5 or 6 resulted in the same memory setting for sorts. Also notice
that the actual size of 80.63 is very close to the predicted setting of 83.25 (84 if a ceiling
function is used) for a DOP of 4.
670 3 distributed_lock_timeout 60
575 3 dml_locks 2924
#### 1 drs_start FALSE
119 3 enqueue_resources 3000
45 2 event
440 2 fal_client
441 2 fal_server
522 3 fast_start_io_target 0
523 3 fast_start_mttr_target 0
625 2 fast_start_parallel_rollback LOW
185 1 file_mapping FALSE
152 2 fileio_network_adapters
154 2 filesystemio_options none
778 2 fixed_date
Mon Sep 05 page 3
INIT.ORA PARAMETER LISTING
_backup_kgc_type specifies 0 0
compression type
used for kgc
Mon Sep 05 page 6
Undocumented Oracle Parameters TEST Database
_db_block_max_scan_pct Percentage of 40 40
buffers to inspect
when looking for
free
_db_file_noncontig_mblock_read_count number of 11 11
noncontiguous db
blocks to be
prefetched
_ksdxw_num_pgw number of 10 10
watchpoints on a
per-process basis
_ksdxw_num_sgw number of 10 10
watchpoints to be
shared by all
processes
_lm_sync_timeout Synchronization
timeout for DLM
reconfiguration
steps
_log_io_size automatically 0 0
initiate log write
if this many redo
blocks in buffer
_log_simultaneous_copies number of 4 4
simultaneous copies
into redo buffer(#
of copy latches)
Mon Sep 05 page 36
Undocumented Oracle Parameters TEST Database
_mv_refresh_delta_fraction delta mv as 10 10
fractional
percentage of size
of mv
_shrunk_aggs_disable_threshold percentage of 60 60
exceptions at which
to switch to full
length aggs
_sort_space_for_write_buffers tenths of 1 1
sort_area_size
devoted to direct
write buffers
_threshold_alerts_enable if 1, issue 1 1
threshold-based
alerts
SQL> @get_undocs
15 rows selected.
Elapsed: 00:03:29.54
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=133048 Card=454775
2 Bytes=513895976)
Statistics
----------------------------------------------------------
609 recursive calls
49 db block gets
79730 consistent gets
89546 physical reads
0 redo size
253974127 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
0 sorts (memory)
1 sorts (disk)
4547752 rows processed
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=108710 Card=259414
8 Bytes=456570048)
Statistics
----------------------------------------------------------
305 recursive calls
29 db block gets
39850 consistent gets
77988 physical reads
0 redo size
128100029 bytes sent via SQL*Net to client
1668013 bytes received via SQL*Net from client
151593 SQL*Net roundtrips to/from client
0 sorts (memory)
1 sorts (disk)
2273876 rows processed
Elapsed: 00:00:00.00
SQL> set autotrace traceonly
SQL> get test_serial
1 select * from test_pga
2* order by district_name,name
SQL> /
Elapsed: 00:04:09.13
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=133048 Card=454775
2 Bytes=513895976)
Statistics
----------------------------------------------------------
609 recursive calls
42 db block gets
79730 consistent gets
135536 physical reads
0 redo size
253978577 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
0 sorts (memory)
1 sorts (disk)
4547752 rows processed
15 rows selected.
Elapsed: 00:00:00.03
SQL> set timing on
SQL> set autotrace traceonly
SQL> get test_parallel
1 select /*+ parallel(test_pga 2) */
2 * from test_pga
3* order by district_name,name
SQL> /
Elapsed: 00:04:24.80
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=73817 Card=4547752
Bytes=513895976)
1 0 PX COORDINATOR
2 1 PX SEND* (QC (ORDER)) OF ':TQ10001' (Cost=73817 Card=454 :Q1001
7752 Bytes=513895976)
2 PARALLEL_TO_SERIAL
3 PARALLEL_COMBINED_WITH_PARENT
4 PARALLEL_COMBINED_WITH_PARENT
5 PARALLEL_TO_PARALLEL
6 PARALLEL_COMBINED_WITH_CHILD
7 PARALLEL_COMBINED_WITH_PARENT
Statistics
----------------------------------------------------------
1160 recursive calls
45 db block gets
79928 consistent gets
157591 physical reads
680 redo size
253686216 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
6 sorts (memory)
2 sorts (disk)
4547752 rows processed
140000000
120000000
100000000
80000000
60000000
40000000
20000000
0
50905115712
50905115554
50905115613
50905115633
50905115652
50905115732
50905115751
50905115811
50905115830
50905115850
50905115909
50905115929
50905115948
50905120008
Session 632
Timestamp Session 633
Predicted Actual
166.5 142.8828125
PGA_AGGREGATE_TARGET 4g, 400M _pga_max_size, 333M
_smm_px_max_size, DOP 3
SQL> show parameter
15 rows selected.
Elapsed: 00:00:00.01
SQL> set autotrace traceonly
SQL> get test_parallel
1 select /*+ parallel(test_pga 3) */
2 * from test_pga
3* order by district_name,name
SQL> /
Elapsed: 00:04:07.17
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=49201 Card=4547752
Bytes=513895976)
1 0 PX COORDINATOR
2 1 PX SEND* (QC (ORDER)) OF ':TQ10001' (Cost=49201 Card=454 :Q1001
7752 Bytes=513895976)
2 PARALLEL_TO_SERIAL
3 PARALLEL_COMBINED_WITH_PARENT
4 PARALLEL_COMBINED_WITH_PARENT
5 PARALLEL_TO_PARALLEL
6 PARALLEL_COMBINED_WITH_CHILD
7 PARALLEL_COMBINED_WITH_PARENT
Statistics
----------------------------------------------------------
572 recursive calls
44 db block gets
79860 consistent gets
150420 physical reads
0 redo size
253646986 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
3 sorts (memory)
2 sorts (disk)
4547752 rows processed
111
Predicted
Session 633
Session 632
Session 629
20000000
40000000
60000000
80000000
0
100000000
120000000
Actual
50905120841
97.57813
50905120858
50905120916
50905120933
50905120951
50905121008
50905121026
50905121043
50905121101
Timestamp
Session Sort Memory DOP3
50905121118
50905121136
50905121153
50905121210
50905121228
50905121245
PGA_AGGREGATE_TARGET 4g, 400M _pga_max_size, 333M
_smm_px_max_size, 4 DOP
SQL> show parameters
15 rows selected.
Elapsed: 00:00:00.01
SQL> set autotrace traceonly
SQL> get test_parallel
1 select /*+ parallel(test_pga 4) */
2 * from test_pga
3* order by district_name,name
SQL> /
Elapsed: 00:04:03.77
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=36897 Card=4547752
Bytes=513895976)
1 0 PX COORDINATOR
2 1 PX SEND* (QC (ORDER)) OF ':TQ10001' (Cost=36897 Card=454 :Q1001
7752 Bytes=513895976)
2 PARALLEL_TO_SERIAL
3 PARALLEL_COMBINED_WITH_PARENT
4 PARALLEL_COMBINED_WITH_PARENT
5 PARALLEL_TO_PARALLEL
6 PARALLEL_COMBINED_WITH_CHILD
7 PARALLEL_COMBINED_WITH_PARENT
Statistics
----------------------------------------------------------
615 recursive calls
58 db block gets
79861 consistent gets
150428 physical reads
672 redo size
253736283 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
3 sorts (memory)
3 sorts (disk)
4547752 rows processed
70000000
60000000
50000000
40000000
30000000
20000000
10000000
0
50905122048
50905122121
50905122154
50905122104
50905122137
50905122210
50905122227
50905122243
50905122300
50905122316
50905122333
50905122349
50905122405
50905122422
50905122438
Session 629
Session 631
Session 632
Session 634
Timestamp
Predicted Actual
83.25 80.63281
PGA_AGGREGATE_TARGET 4g, 400M _pga_max_size, 333M
_smm_px_max_size, 5 DOP
SQL> show parameters
15 rows selected.
Elapsed: 00:00:00.00
SQL> set autotrace traceonly
SQL> get test_parallel
1 select /*+ parallel(test_pga 5) */
2 * from test_pga
3* order by district_name,name
SQL> /
Elapsed: 00:04:19.20
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=29514 Card=4547752
Bytes=513895976)
1 0 PX COORDINATOR
2 1 PX SEND* (QC (ORDER)) OF ':TQ10001' (Cost=29514 Card=454 :Q1001
7752 Bytes=513895976)
2 PARALLEL_TO_SERIAL
3 PARALLEL_COMBINED_WITH_PARENT
4 PARALLEL_COMBINED_WITH_PARENT
5 PARALLEL_TO_PARALLEL
6 PARALLEL_COMBINED_WITH_CHILD
7 PARALLEL_COMBINED_WITH_PARENT
Statistics
----------------------------------------------------------
667 recursive calls
66 db block gets
79861 consistent gets
157598 physical reads
628 redo size
253806663 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
2 sorts (memory)
5 sorts (disk)
4547752 rows processed
66.6
Predicted
Session
Session
Session
Session
Session
0
10000000
20000000
30000000
40000000
50000000
60000000
70000000
638
634
632
629
618
50905122757
Actual
55.0625
50905122815
50905122834
50905122852
50905122911
50905122929
50905122948
50905123006
50905123025
Timestamp
50905123043
Session Sort Memory 5 DOP
50905123102
50905123120
50905123139
50905123157
PGA_AGGREGATE_TARGET 4G, 400M _pga_max_size, 333M
_smm_px_max_size, 6 DOP
SQL> show parameter
15 rows selected.
Elapsed: 00:00:00.01
SQL> set autotrace traceonly
SQL> get test_parallel
1 select /*+ parallel(test_pga 6) */
2 * from test_pga
3* order by district_name,name
SQL> /
Elapsed: 00:04:45.62
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=24593 Card=4547752
Bytes=513895976)
1 0 PX COORDINATOR
2 1 PX SEND* (QC (ORDER)) OF ':TQ10001' (Cost=24593 Card=454 :Q1001
7752 Bytes=513895976)
2 PARALLEL_TO_SERIAL
3 PARALLEL_COMBINED_WITH_PARENT
4 PARALLEL_COMBINED_WITH_PARENT
5 PARALLEL_TO_PARALLEL
6 PARALLEL_COMBINED_WITH_CHILD
7 PARALLEL_COMBINED_WITH_PARENT
Statistics
----------------------------------------------------------
660 recursive calls
64 db block gets
79861 consistent gets
155978 physical reads
680 redo size
253759906 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
3 sorts (memory)
5 sorts (disk)
4547752 rows processed
SQL> spool of
SQL> select * from test_results;
55.5
Predicted
Session 632
Session 631
Session 628
Session 617
Session 616
Session 615
10000000
20000000
30000000
40000000
50000000
60000000
70000000
0
50905123536
Actual
50905123551
55.0625
50905123605
50905123619
50905123634
50905123648
50905123703
50905123717
50905123732
50905123746
50905123800
50905123815
Timestamp
Session Sort Memory 6 DOP
50905123829
50905123843
50905123858
50905123912
50905123927
50905123941
50905123955
50905124010
PGA_AGGREGATE_TARGET 4G, 400M _pga_max_size, 333M
_smm_px_max_size, 7 DOP
SQL> show parameter
Elapsed: 00:00:00.00
SQL> set autotrace traceonly
SQL> get test_parallel
1 select /*+ parallel(test_pga 7) */
2 * from test_pga
3* order by district_name,name
SQL> /
Elapsed: 00:05:41.19
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=21079 Card=4547752
Bytes=513895976)
1 0 PX COORDINATOR
2 1 PX SEND* (QC (ORDER)) OF ':TQ10001' (Cost=21079 Card=454 :Q1001
7752 Bytes=513895976)
2 PARALLEL_TO_SERIAL
3 PARALLEL_COMBINED_WITH_PARENT
4 PARALLEL_COMBINED_WITH_PARENT
5 PARALLEL_TO_PARALLEL
6 PARALLEL_COMBINED_WITH_CHILD
7 PARALLEL_COMBINED_WITH_PARENT
Statistics
----------------------------------------------------------
1133 recursive calls
67 db block gets
79993 consistent gets
147701 physical reads
680 redo size
253863141 bytes sent via SQL*Net to client
3335525 bytes received via SQL*Net from client
303185 SQL*Net roundtrips to/from client
9 sorts (memory)
4 sorts (disk)
4547752 rows processed
SQL> spool of
Session Sort Size 7 DOP
60000000
Memory (Bytes)
50000000
40000000
30000000
20000000
10000000
0
50905124900
50905125124
50905125222
50905125319
50905124831
50905124929
50905124957
50905125026
50905125055
50905125153
50905125250
50905125348
Session 626
Session 627
Session 628
Session 629
Session 630
Session 631
Session 632 Timestamp
Predicted Actual
DOP 7 47.57143 42.4140625