Abstract:

Oracle Initialization Parameters & Performance View 1. Database version LEO1@LEO1>select * from v$version; BANNER ——————————————————————————-…

Oracle

Initialization parameter

&

Performance View

1.

Database Version

LEO1@LEO1>select * from v$version;

BANNER

——————————————————————————–

Oracle Database11g Enterprise Edition Release 11.2.0.1.0-64bit Production

PL/SQL Release11.2.0.1.0 – Production

The CORE 11.2.0.1.0 Production

TNS for Linux:Version 11.2.0.1.0 – Production

NLSRTL Version11.2.0.1.0 – Production




2.

Set up the

memory_target

Parameter and pass

v$memory_target_advice

Analyze the optimal memory size for the database

Memory_target

:

1.

is

oracle11g

A memory adjustment parameter in,

11g

The automatic memory management aspect continues to be enhanced, originally

10g

Can be in

SGA

For automatic management and distribution,

11g

That is, it can be automatically managed

SGA

And can be automatically managed

PGA

, the two parts of the integrated management, automatic adjustment of all memory area size.

11g

The default for

0

This parameter is static and needs to be restarted to take effect

alter systemset memory_max_target= 1000m scope=spfile;

alter system set memory_target= 1000m scope=spfile;

alter system set sga_max_size=600m scope=spfile;

alter system set pga_aggregate_target=400m scope=spfile;

2.memory_max_target

Is to set

Oracle

How much physical memory does it take up? One is

Oracle SGA

How much memory space can the region occupy

+PGA

How much space is there,

memory_max_target

is

memory_target

Upper limit, if only set

memory_max_target

There is no set

memory_target

,

Oracle

think

memory_target=0

Do not use automatic memory management.

3.

If you just set

memory_target

, no Settings

memory_max_target

,

Oracle

automatically

memory_max_target

Set to

memory_target

.

4.

If both values are set, then

memory_target

The upper limit of is

memory_max_target

.

This is the parameter value on my database

LEO1@LEO1> showparameter memory_max_target

NAME TYPE VALUE

———————————————– ——————————

memory_max_target big integer 652M

LEO1@LEO1> showparameter memory_target

NAME TYPE VALUE

———————————————– ——————————

memory_target big integer 652M

5. 10g

the

sga_max_size

It’s dynamic allocation

Shared Pool Size,database buffer cache,largepool,java pool

.

redo log buffer

Size, according to

Oracle

Run state to reassign

SGA

Size of each memory area.

PGA

in

10g

Need to be set separately (manual management).

The experiment

Let’s make it clear through the following commands

memory_target

Set up and

PGA

and

SGA

The relationship between

(

1

)

memory_target

Set to the

0

value

Memory_Target=SGA_TARGET+PGA_AGGREGATE_TARGET

And the magnitude is equal to

memory_max_size

Consistent.

sga_target

and

pga_aggregate_target

If the size is set, these two parameters will be used as the minimum starting value

sga_target

Set the size,

pga_aggregate_target

Not set size

then

pga_aggregate_target

The initialization value

=memory_target-sga_target

sga_target

Without setting the size,

pga_aggregate_target

Set the size

then

sga_target

The initialization value

=memory_target-pga_aggregate_target

sga_target

and

pga_aggregate_target

None of them are set to size

Oracle 11g

Size is automatically allocated based on database health. However, there is a fixed percentage allocated when the database is started:

sga_target =memory_target *60% pga_aggregate_target=memory_target *40%

(

2

)

memory_target

No setting or equal

0

(

11g

The default for

0

)

11g

The default for

0

It’s canceled in its initial state

memory_target

The role of total and

10g

Consistent in memory management, full downward compatibility.

(There are also three ways to get it right

SGA

and

PGA

Size to allocate)

SGA_TARGET

If the value is set, it will be automatically adjusted

SGA

In the

shared pool,buffer cache,redo logbuffer,java pool,larger pool

Memory area,

PGA

Is dependent on

pga_aggregate_target

The size is set separately.

sga

and

pga

It can’t grow and shrink automatically.

SGA_target

and

PGA_AGGREGATE_TARGET

None of them are set,

SGA

The size of each memory area should be clearly set, can not automatically adjust the size of each memory area.

PGA

It doesn’t automatically grow and contract.

memory_max_target

Set up and

memory_target =0

This situation and

10g

The same does not use memory for automatic management

LEO1@LEO1> showparameter target

NAME TYPE VALUE

———————————————– ——————————

archive_lag_target integer 0

db_flashback_retention_target integer 1440

fast_start_io_target integer 0

fast_start_mttr_target integer 0

memory_max_target big integer 652M

memory_target big integer 652M

parallel_servers_target integer 8

pga_aggregate_target big integer 0

sga_target big integer 0

Now we see

sga_target

and

pga_aggregate_target

The values are

0

By the

oracle

Automatic resizing,

memory_target

and

memory_max_target

Is the size of the

652M

LEO1@LEO1>select * from v$memory_target_advice;

Analyze the optimal memory size for the database

MEMORY_SIZE MEMORY_SIZE_FACTORESTD_DB_TIME ESTD_DB_TIME_FACTOR VERSION

—————————– ———— ——————- ———-

489.75 5522 1.0002 0

652 1 5521 1 0

815 1.25 5518.9994 0

978 1.5 5517.9993 0

1141 1.75 5517.9992 0

1304 2 5517.9992 0

MEMORY_SIZE

:

oracle

Recommended memory size

MEMORY_SIZE_FACTOR

: Memory baseline factor,

0.25, 0.5, 0.75, 1, 1.5, 1.75, and 2

ESTD_DB_TIME

:

Forcurrent memory size (MEMORY_SIZE_FACTOR = 1), the amount of database time requiredto complete the current workload. For a proposed memory size, the estimatedamount of database time that would be required if the MEMORY_TARGET parameterwere changed to the proposed size.

(Official documentation)

When the memory baseline factor is

1

, the total database time required to complete the current database workload (that is, the database time consumed by all users), which is a recommended value that will be based on

memory_target

The parameters change

ESTD_DB_TIME_FACTOR

:

Fora proposed memory size, ratio of estimated database time to current databasetime

(Official documentation)

A scaling factor that consumes database time

VERSION

:

Versionnumber of this recommendation (this snapshot of the V$MEMORY_TARGET_ADVICE view

v$memory_target_advice

The version number of this view snapshot

1.

when

memory_target=489M

When,

ESTD_DB_TIME=5522

2.

when

memory_target=652M

When,

ESTD_DB_TIME=5521

The current value

3.

when

memory_target=815M

When,

ESTD_DB_TIME=5518

4.

when

memory_target=978M

When,

ESTD_DB_TIME=5517

5.

when

memory_target=1141M

When,

ESTD_DB_TIME=5517

6.

when

memory_target=1304M

When,

ESTD_DB_TIME=5517

From the above system resource consumption,

memory_target=489M

Is before

652M

Three quarters, but

ESTD_DB_TIME

To increase the

1

The price is very high, we can put

memory_target=

Modified into

489M

To save our memory resources

LEO1@LEO1>alter system set memory_max_target=489m scope=spfile;

System altered.

LEO1@LEO1>alter system set memory_target=489m scope=spfile;

System altered.

LEO1@LEO1> showparameter target

NAME TYPE VALUE

———————————————– ——————————

archive_lag_target integer 0

db_flashback_retention_target integer 1440

fast_start_io_target integer 0

fast_start_mttr_target integer 0

memory_max_target big integer 652M

memory_target big integer 652M

parallel_servers_target integer 8

pga_aggregate_target big integer 0

sga_target big integer 0

Now it’s just modified

spfile

The contents of the parameter file take effect only after the database is restarted

LEO1@LEO1>shutdown immediate

ORA-01031:insufficient privileges

Insufficient permissions

LEO1@LEO1> conn/ as sysdba

switch

sys

The user

Connected.

SYS@LEO1>shutdown immediate

Shut down the instance

Database closed.

Databasedismounted.

ORACLE instanceshut down.

SYS@LEO1>startup

ORACLE instancestarted.

Total SystemGlobal Area 513585152 bytes

Fixed Size 2214856 bytes

Variable Size 314573880 bytes

DatabaseBuffers 188743680 bytes

Redo Buffers 8052736 bytes

Database mounted.

Database opened.

SYS@LEO1> showparameter target

NAME TYPE VALUE

———————————————– ——————————

archive_lag_target integer 0

db_flashback_retention_target integer 1440

fast_start_io_target integer 0

fast_start_mttr_target integer 0

memory_max_target big integer 492M oracle

Made a few corrections

memory_target big integer 492M

parallel_servers_target integer 8

pga_aggregate_target big integer 0

sga_target big integer 0

Summary: We can base on

v$memory_target_advice

View to make reasonable adjustments

memory_target

To improve resource utilization.




3.

By adjusting the parameters

optimizer_index_cost_adj

Size of demo

SQL

Generate different execution plans

Optimizer_index_cost_adj

: This parameter is used for

CBO

The weight correction in calculating the index cost

Optimizer_index_cost_adj

The higher the value of, the lower the chance of using the index,

CBO

Full table scan is preferred

Optimizer_index_cost_adj

The lower the value of, the higher the chance of using the index,

CBO

Tend to go index

Optimizer_index_cost_adj

The default value is

100

SYS@LEO1> showparameter optimizer_index_cost_adj;

NAME TYPE VALUE

———————————————– ——————————

optimizer_index_cost_adj integer 100

The experiment

LEO1@LEO1> droptable leo1 purge;

Clean up the environment

Table dropped.

LEO1@LEO1>create table leo1 as select * from dba_objects where rownum<200;

create

leo1

table

199

records

Table created.

LEO1@LEO1>create index idx_leo1 on leo1(object_id);

create

idx_leo1 B-tree

The index

Index created.

Let’s look at when

optimizer_index_cost_adj=100

Time execution plan

LEO1@LEO1> setautotrace trace explain

LEO1@LEO1>select * from leo1;

Execution Plan

———————————————————-

Plan hash value:2716644435

————————————————————————–

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

————————————————————————–

| 0 | SELECT STATEMENT | | 199 | 41193 | 3 (0)| 00:00:01 |

| 1 |
TABLE ACCESS FULL
| LEO1 | 199 | 41193 | 3 (0)| 00:00:01 |

————————————————————————–

It’s a full table scan, and at this point we’re only doing it

19

For sub-consistent read, only data blocks are scanned but index blocks are not

Statistics

———————————————————-

0 recursive calls

0 db block gets

19 consistent gets

produce

19

Consistency read

0 physical reads

0 redo size

20823 bytes sent via SQL*Net to client

667 bytes received via SQL*Net from client

15 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

199 rows processed

LEO1@LEO1>alter session set optimizer_index_cost_adj=10;

from

100

Modified into

10

Session altered.

As this parameter gets smaller,

CBO

Prefer to go to the index

LEO1@LEO1>select * from leo1 where object_id<=800;

Execution Plan

———————————————————-

Plan hash value:1434365503

—————————————————————————————-

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

—————————————————————————————-

| 0 | SELECT STATEMENT | | 199 | 41193 | 1 (0)| 00:00:01 |

| 1 | TABLE ACCESS BY INDEX ROWID | LEO1 | 199| 41193 | 1 (0)| 00:00:01 |

|* 2 | INDEX RANGE SCAN |IDX_LEO1 | 199 | | 1 (0)| 00:00:01 |

—————————————————————————————-

It’s going to the index, and that’s when we happen

32

Subconsistent read, first scan the index block and then according to

rowid

Scanning data blocks

Statistics

———————————————————-

0 recursive calls

0 db block gets

32 consistent gets

produce

32

Consistency read

0 physical reads

0 redo size

20823 bytes sent via SQL*Net to client

667 bytes received via SQL*Net from client

15 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts(disk)

199 rows processed

Summary: we generate more consistent reads from the same index set than from a full table scan

IO

The more times, the more consumed the system

IO

More resources, this is not reasonable, we should avoid in production.


4.

By setting parameters

DB_FILE_MULTIBLOCK_READ_COUNT

Different values, demo pairs

SQL

Impact of efficiency

db_file_multiblock_read_count

This initialization parameter is called how many blocks to read at a time

or

Multiple data blocks can be read at a time. This parameter value is not infinite, on most platforms

oracle

Are all

128

. general

oracle block size =8k

128*8=1M

That is to say

1M

Is the maximum for most operating systems at one time

IO

If there are any other restrictions to come from here

1M

It’s going to subtract the initialization parameters

db_file_multiblock_read_count

The reason why the maximum value of

128

And also for conservative strategy.

Scene:

(

1

) Full table scan

FTS

(

FULL TABLE SCAN

) : at this time

oracle

Multiple block reads are supported

(

2

Index fast full scan

IFFS

(

INDEX FAST FULL SCAN

) : Multiple block reads are supported when indexes are read in parallel

(

3

)

OLAP

: You can make it bigger, but not as big as possible

(

4

) is also affected by the operating system

IO

Limitations of its own

The experiment

LEO1@LEO1> droptable leo2 purge;

Clean up the environment

Table dropped.

LEO1@LEO1> droptable leo3 purge;

Table dropped.

LEO1@LEO1>create table leo2 as select * from dba_objects;

create

leo2

table

Table created.

LEO1@LEO1>create table leo3 as select * from dba_objects;

create

leo3

table

Table created.

LEO1@LEO1>create index idx_leo3 on leo3(object_id);

create

idx_leo3

The index

Index created.

LEO1@LEO1>select segment_name,segment_type,bytes/1024/1024 from user_segments where segment_namein (‘LEO2′,’LEO3′,’IDX_LEO3’);

SEGMENT_NAME SEGMENT_TYPE BYTES/1024/1024

——————————————————————————————-

IDX_LEO3 INDEX 2

LEO3 TABLE 9

LEO2 TABLE 9

LEO2

Table size is

9M

(section head

+

Data),

LEO3

Table size

9+2=11M

(table

+

Index)

LEO1@LEO1>alter session set db_file_multiblock_read_count=16;

Set multiple read blocks to read at a time

16

A data block

Session altered.

LEO1@LEO1> showparameter db_file_multiblock_read_count 16

block

*8k=128k

NAME TYPE VALUE

———————————————– ——————————————

db_file_multiblock_read_count integer 16

LEO1@LEO1>select count(*) from leo2;

Execution Plan

———————————————————-

Plan hash value:3963694794

——————————————————————-

| Id | Operation | Name | Rows | Cost (%CPU)| Time |

——————————————————————-

| 0 | SELECT STATEMENT | | 1 | 233 (1)| 00:00:03 |

| 1 | SORT AGGREGATE | | 1 | | |

| 2 | TABLE ACCESS FULL | LEO2 | 73470 | 233 (1)| 00:00:03 |

——————————————————————-

Statistics

———————————————————-

210 recursive calls

0 db block gets

1119 consistent gets

1025 physical reads

0 redo size

528 bytes sent via SQL*Net to client

524 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

5 sorts (memory)

0 sorts (disk)

1 rows processed

Generally perform

2

Once again, the statistics will stabilize

LEO1@LEO1>select count(*) from leo2;

Execution Plan

———————————————————-

Plan hash value:3963694794

——————————————————————-

| Id | Operation | Name | Rows | Cost (%CPU)| Time |

——————————————————————-

| 0 | SELECT STATEMENT | | 1 | 233 (1)| 00:00:03 |

| 1 | SORT AGGREGATE | | 1 | | |

2 | |
TABLE ACCESS FULL
| LEO2 | 73470 | 233 (1)| 00:00:03 |

——————————————————————-

A full table scan uses multiple block reads

Statistics

———————————————————-

0 recursive calls

0 db block gets

1030 consistent gets 1030

block

*8K=8240k

Approximately equal to the

9M

0 physical reads

0 redo size

528 bytes sent via SQL*Net to client

524 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

We were using the

1030/16 = 64.375

Time,

oracle

Need to read

64.375

time

IO

To read all the records.

LEO1@LEO1> selectcount(object_id) from leo3;

Execution Plan

———————————————————-

Plan hash value:3677630522

———————————————————————————-

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

———————————————————————————-

| 0 | SELECT STATEMENT | | 1 | 13 | 40 (0)| 00:00:01 |

| 1 | SORT AGGREGATE | | 1 | 13 | | |

| 2 | INDEX FAST FULL SCAN| IDX_LEO3 | 71702 | 910K| 40 (0)| 00:00:01 |

———————————————————————————-

Statistics

———————————————————-

4 recursive calls

0 db block gets

236 consistent gets

160 physical reads

0 redo size

536 bytes sent via SQL*Net to client

524 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

perform

2

through

LEO1@LEO1> selectcount(object_id) from leo3;

Execution Plan

———————————————————-

Plan hash value:3677630522

———————————————————————————-

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

———————————————————————————-

| 0 | SELECT STATEMENT | | 1 | 13 | 40 (0)| 00:00:01 |

| 1 | SORT AGGREGATE | | 1 | 13 | | |

2 | |
INDEX FAST FULL SCAN
| IDX_LEO3 | 71702 | 910K| 40 (0)| 00:00:01 |

———————————————————————————-

Index quick full scan uses multiple block reads

Statistics

———————————————————-

0 recursive calls

0 db block gets

168 consistent gets 168

block

*8k=1344k

Approximately equal to the

2M

0 physical reads

0 redo size

536 bytes sent via SQL*Net to client

524 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

We were using the

168/16 = 10.5

Time,

oracle

Need to read

10.5

time

IO

In order to calculate the final result

LEO1@LEO1> setautotrace off

LEO1@LEO1>alter session set db_file_multiblock_read_count=128;

Set multiple read blocks to read at a time

128

A data block

Session altered.

LEO1@LEO1> showparameter db_file_multiblock_read_count 128

block

*8k=1M

NAME TYPE VALUE

———————————————– ——————————

db_file_multiblock_read_count integer 128

LEO1@LEO1> setautotrace traceonly

LEO1@LEO1>select count(*) from leo2;

Execution Plan

———————————————————-

Plan hash value:3963694794

——————————————————————-

| Id | Operation | Name | Rows | Cost (%CPU)| Time |

——————————————————————-

| 0 | SELECT STATEMENT | | 1 | 185 (1)| 00:00:03 |

| 1 | SORT AGGREGATE | | 1 | | |

2 | |
TABLE ACCESS FULL
| LEO2 | 73470 | 185 (1)| 00:00:03 |

——————————————————————-

After parameter adjustment

cost

From the original

233

To reduce the

185

.

IO

If the cost is reduced, the parameters are in effect

Statistics

———————————————————-

0 recursive calls

0 db block gets

1030 consistent gets 1030/128 = 8.04

time

IO

0 physical reads

0 redo size

528 bytes sent via SQL*Net to client

524 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

We were using the

1030/128 = 8.04

Time,

oracle

From the read

64.375

Time is reduced to

8.04

Time,

IO

Resource consumption is greatly reduced,

SQL

Efficiency has been greatly improved.

LEO1@LEO1> selectcount(object_id) from leo3;

Execution Plan

———————————————————-

Plan hash value:3677630522

———————————————————————————-

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

———————————————————————————-

| 0 | SELECT STATEMENT | | 1 | 13| 32 (0)| 00:00:01 |

| 1 | SORT AGGREGATE | | 1 | 13 | | |

2 | |
INDEX FAST FULL SCAN
|IDX_LEO3 | 71702 | 910K| 32 (0)| 00:00:01 |

———————————————————————————-

Index quick full scan

cost

From the original

40

To reduce the

32

.

IO

The cost is also reduced, which means the parameters are working

Statistics

———————————————————-

0 recursive calls

0 db block gets

168 consistent gets 168/128 = 1.3125

time

0 physical reads

0 redo size

536 bytes sent via SQL*Net to client

524 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rowsprocessed

Summary:

oracle

The index from

10.5

Time is reduced to

1.3125

Time,

IO

The frequency is greatly reduced,

SQL

The efficiency of reading naturally increases.





This article from ztfriend 51 cto blog, the original link: http://blog.51cto.com/leonarding/1143571, if you want to reprint, please contact our author


Copyright Notice: The content of this article is contributed by Internet users, copyright belongs to the author, the community does not have the ownership, also do not assume the relevant legal responsibility. If you find any content suspected of plagiarism in our community, you are welcome to send an email to [email protected] to report and provide relevant evidence. Once verified, our community will immediately delete the content suspected of infringement.


The original link