Showing posts with label Oracle L1. Show all posts
Showing posts with label Oracle L1. Show all posts

Jan 16, 2024

Resource Manager and Task Schedular

Resource Manager and Task Schedular-


In Oracle Database, the Resource Manager is a feature that allows you to manage and allocate resources among different users and applications. It enables you to control the number of resources (CPU, memory, and parallel execution servers) consumed by database sessions and helps in preventing runaway queries or resource-intensive operations from adversely impacting the overall performance of the database. 

Key features and components of Oracle Resource Manager include: 


Consumer Groups: 

Resource Manager organizes database sessions into "consumer groups." Each consumer group represents a category of users or applications that share similar resource requirements. 


Resource Plans: 

Resource plans are a set of rules that define how resources should be allocated among different consumer groups. They specify the resource allocation policies, priorities, and limits for each group. 


Directive and Consumer Group Mapping: 

Directives are rules defined within a resource plan that specify how resources should be allocated to consumer groups. These directives may include rules for CPU usage, parallel execution servers, and other resources. 

Consumer Group Mapping associates database sessions with specific consumer groups. 


Parallel Degree Limits: 

Resource Manager allows you to set limits on the degree of parallelism for specific operations. This helps in controlling the parallel execution of queries to prevent excessive parallelism. 

 

Sub-Plan and Plan Directives: 

Within a resource plan, you can define sub-plans and plan directives to further customize resource allocation for specific scenarios. 


Automatic Consumer Group Mapping: 

Oracle Database can automatically map sessions to consumer groups based on user attributes, application attributes, or other criteria defined by the database administrator. 

 

Monitoring and Statistics: 

Resource Manager provides monitoring views and statistics to track resource usage, plan effectiveness, and other relevant metrics. 

 

Here's a simple example of creating a basic resource plan with Oracle Resource Manager: 


-- Create a simple resource plan 

BEGIN 

DBMS_RESOURCE_MANAGER.create_pending_area(); 

DBMS_RESOURCE_MANAGER.create_consumer_group('low_priority'); 

DBMS_RESOURCE_MANAGER.create_consumer_group('high_priority'); 

DBMS_RESOURCE_MANAGER.create_plan('my_plan'); 

DBMS_RESOURCE_MANAGER.create_plan_directive( 

plan               => 'my_plan', 

group_or_subplan   => 'low_priority', 

switch_group       => 'TRUE', 

max_utilization    => 40); 

DBMS_RESOURCE_MANAGER.create_plan_directive( 

plan               => 'my_plan', 

group_or_subplan   => 'high_priority', 

switch_group       => 'TRUE', 

max_utilization    => 60); 

DBMS_RESOURCE_MANAGER.submit_pending_area(); 

END; 

In this example, a resource plan named 'my_plan' is created with two consumer groups ('low_priority' and 'high_priority'). Directives are then defined to allocate resources based on the maximum utilization for each consumer group. 

Resource Manager is a powerful tool for managing the performance of a multi-user Oracle Database by ensuring that resources are allocated in a controlled and predictable manner. It is particularly useful in environments where there is a need to prioritize and allocate resources among different types of workloads or users. 

 

Task Schedular-

Ask scheduling in Oracle typically involves using the Oracle Scheduler, a comprehensive job scheduling solution provided by Oracle Database. The Oracle Scheduler allows you to automate and manage various database tasks, such as running PL/SQL procedures, calling external programs, or executing SQL scripts at specified intervals. 

Here are the basic steps to create and manage scheduled tasks in Oracle: 


Create a Job: 

You can create a job using the DBMS_SCHEDULER.CREATE_JOB procedure. 

Specify the job name, job type (PL/SQL block, stored procedure, etc.), and other relevant parameters. 

BEGIN 

  DBMS_SCHEDULER.CREATE_JOB ( 

    job_name        => 'MY_JOB', 

    job_type        => 'PLSQL_BLOCK', 

    job_action      => 'BEGIN my_procedure; END;', 

    start_date      => SYSTIMESTAMP, 

    repeat_interval => 'FREQ=DAILY; BYHOUR=0; BYMINUTE=0; BYSECOND=0', 

    enabled         => TRUE 

  ); 

END; 

Task scheduling in Oracle typically involves using the Oracle Scheduler, a comprehensive job scheduling solution provided by Oracle Database. The Oracle Scheduler allows you to automate and manage various database tasks, such as running PL/SQL procedures, calling external programs, or executing SQL scripts at specified intervals. 

Here are the basic steps to create and manage scheduled tasks in Oracle: 


Create a Job: 

 You can create a job using the DBMS_SCHEDULER.CREATE_JOB procedure. 

Specify the job name, job type (PL/SQL block, stored procedure, etc.), and other relevant parameters. 

BEGIN 

  DBMS_SCHEDULER.CREATE_JOB ( 

    job_name        => 'MY_JOB', 

    job_type        => 'PLSQL_BLOCK', 

    job_action      => 'BEGIN my_procedure; END;', 

    … 


-- Disable a job 


BEGIN 

  DBMS_SCHEDULER.DISABLE('MY_JOB'); 

END; 

-- Enable a job 

BEGIN 

  DBMS_SCHEDULER.ENABLE('MY_JOB'); 

END; 

Dropping a Job: 

If you want to remove a job from the scheduler, use the DBMS_SCHEDULER.DROP_JOB procedure. 

sql 

BEGIN 

  DBMS_SCHEDULER.DROP_JOB('MY_JOB'); 

END; 

/

Remember to have the necessary privileges to create and manage jobs (e.g., CREATE JOB, CREATE PROCEDURE, CREATE ANY JOB, etc.). 

Adjust the parameters and schedule according to your specific requirements. The provided example is a basic illustration, and you may need to customize it based on your needs. 

 

--BY Tarif Ahmed

Jan 11, 2024

New Features of Oracle 19c

New Features of Oracle 19c-


Oracle Database 19c refers to the 19th version of the Oracle Database, which is a relational database management system (RDBMS) developed and marketed by Oracle Corporation. The "c" in 19c stands for "Cloud," indicating Oracle's commitment to cloud computing and cloud-based solutions. Oracle 19c is the successor to Oracle Database 18c and comes with several new features, enhancements, and improvements over its predecessors.




Oracle Database 19c, released by Oracle Corporation, brought several significant features and enhancements to improve performance, manageability, and security. Here's a more detailed explanation:

 

 

Multitenant Architecture Enhancements:

Oracle 19c focused on enhancing its Multitenant Architecture, allowing for more efficient management and consolidation of databases. Notable improvements included features like PDB snapshots, hot cloning, and cross-container operations, streamlining administrative tasks.

 

Automatic Indexing:

A major highlight was the introduction of Automatic Indexing. This feature employs machine learning algorithms to automatically create and fine-tune indexes based on the observed workload patterns, simplifying the database optimization process.

 

Real-Time Statistics:

The addition of Real-Time Statistics aimed at improving query optimization. This feature ensures that the query optimizer has access to the most up-to-date statistics, particularly beneficial for partitioned tables.

 

SQL Quarantine:

Oracle 19c introduced SQL Quarantine, a feature designed to prevent the execution of SQL statements identified as problematic. This helps safeguard the database from potential performance issues caused by problematic queries.

 

In-Memory Database Enhancements:

Oracle Database In-Memory received enhancements, making it more versatile for both analytics and mixed workload environments. These improvements contributed to faster query performance and improved overall efficiency.

 

Blockchain Tables:

The introduction of Blockchain Tables aimed at simplifying the development and management of blockchain-enabled applications within the Oracle Database environment.

 

Enhanced Security Features:

Security received attention with various enhancements, including the introduction of new algorithms for Transparent Data Encryption (TDE), improvements in Data Redaction, and better integration with Oracle Key Vault for enhanced data protection.

 

JSON Enhancements:

Oracle 19c improved support for working with JSON data, introducing features like JSON_TRANSFORM, JSON_TABLE, and JSON_EXISTS, making it more seamless to work with JSON documents within the database.

 

Shading Enhancements:

Oracle Shading, a feature enabling the distribution and management of data across multiple discrete Oracle databases, saw improvements in manageability and performance, providing a more robust and scalable solution.

 

Database Replay:

The Database Replay functionality was enhanced, allowing for more effective testing and validation of database changes before implementing them in a production environment, reducing the risk of potential issues.

 

Machine Learning in the Database:

Oracle 19c integrated machine learning algorithms directly into the database. This inclusion allowed users to perform tasks such as predictive analysis, anomaly detection, and clustering without the need for external tools, bringing machine learning capabilities closer to the data.

Jan 4, 2024

Top 10 performance Counters in Oracle Database19c

Top 10 performance Counters in Oracle Database19c


Monitoring performance counters is critical for optimizing Oracle Database performance. Here are ten significant performance counters (also called as performance metrics or statistics) to consider while analyzing an Oracle 19c database's performance:


 

Buffer Cache Hit Ratio-

Indicates the efficiency of the buffer cache by measuring the ratio of cache hits to total requests.




Query-

SELECT 1 - (SUM(decode(name, 'physical reads', value, 0)) / SUM(decode(name, 'db block gets', value, 0))) AS buffer_cache_hit_ratio

FROM v$sysstat;

 

Library Cache Hit Ratio-

Measures the efficiency of SQL and PL/SQL statement caching by showing the ratio of hits to total requests in the library cache.




Query-

SELECT SUM(pinhits)/SUM(pins) AS library_cache_hit_ratio

FROM v$librarycache;

 

Latch Contention-

Identifies latch contention by monitoring latch statistics

Query-

SELECT name, gets, misses, sleeps

FROM v$latch

WHERE sleeps > 0;

 

Wait Events-

Monitors various wait events to identify what the database is waiting on.




Query-

SELECT event, total_waits, time_waited

FROM v$system_event

WHERE event NOT LIKE '%idle%'

ORDER BY total_waits DESC;

 

CPU Usage-

Monitors CPU-related statistics, such as CPU usage percentage.




Query-

SELECT ROUND(value, 2) AS cpu_usage_percentage

FROM v$osstat

WHERE stat_name = 'BUSY_TIME';

 

Disk I/O Statistics-

Monitors read and write I/O operations to identify potential disk I/O bottlenecks.

Query-

SELECT file#, name, phyrds, phywrts

FROM v$filestat;

 

PGA and SGA Memory Usage-

Tracks PGA and SGA memory usage to ensure efficient memory utilization.

Query-

SELECT * FROM v$pgastat;

SELECT * FROM v$sgastat;

 

SQL Statement Execution Times-

Identifies long-running or frequently executed SQL statements.




Query-

SELECT sql_id, elapsed_time, buffer_gets, disk_reads

FROM v$sql

WHERE elapsed_time > 1000 -- Adjust as needed

ORDER BY elapsed_time DESC;

 

Active Session History (ASH)-

Reviews active session history to analyze and troubleshoot database performance at the session level.




Query-

SELECT sample_id, session_id, user_id, program, sql_id, event, wait_class, time_waited

FROM v$active_session_history

WHERE sample_time > SYSTIMESTAMP - INTERVAL '1' HOUR; -- Adjust time window as needed

 

Temp Space Usage-

Monitors temporary tablespace usage, especially during complex queries or sorting operations

Query-

SELECT tablespace, used_blocks, free_blocks, round(used_blocks * 8 / 1024, 2) AS used_mb

FROM v$sort_segment;

Jan 2, 2024

 

Startup In Oracle Database

Summary: in this tutorial, you will learn how to use the Oracle STARTUP command to

start an Oracle Database instance.

To start up a database instance, you use the STARTUP command:

When the Oracle Database starts an instance, it goes through the following stages: NOMOUNTMOUNT, and OPEN


The STARTUP command allows you to control the stage of the database instance.

NOMOUNT stage

In the NOMOUNT stage, Oracle carries the following steps:

·         First, search for a server parameter file in the default location. You can override the default behavior by using the SPFILE or PFILE parameters in the STARTUP command.

·         Next, read the parameter file to get the values of the initialization parameters.

·         Then, allocate the system global area (SGA) based on the initialization parameter settings.

·         After that, start the Oracle background processes such as SMONPMON, and LGWR.

·         Finally, open the alert log and trace files and record all explicit parameters to the alert log in the valid parameter syntax.

At the NOMOUNT stage, Oracle does not associate the database with the instance.

MOUNT stage:

In the MOUNT stage, Oracle associates a database with an instance. In other words, the instance mounts the database.

The instance carries the following steps to mount a database:

·       First, get the name of the database control files specified in the CONTROL_FILE initialization parameter.

·      Second, open the control files.

·      Third, find the name of the data files and the online redo log files.

When a database is mounted, the database is only available to database administrators, not all users


Select instance_name,status from  v$instance


OPEN stage:

In the OPEN stage, Oracle performs the following actions:

·         First, open the online data files in tablespaces other than the undo tablespaces.

·         Then, select an undo tablespace. The instance uses the default undo tablespace if an undo tablespace is specified in the UNDO_TABLESPACE initialization parameter. Otherwise, it will select the first available undo tablespace.

·         Finally, open the online redo log files.

When Oracle opens a mounted database, the database is available for normal operations.

Alter database open;


SELECT  instance_name,status  FROM  v$instance;