

# Oracle and PostgreSQL configuration
<a name="chap-oracle-aurora-pg.configuration"></a>

This section provides pages about Oracle and PostgreSQL configuration topics.

**Topics**
+ [Oracle and Aurora for PostgreSQL upgrades](chap-oracle-aurora-pg.configuration.upgrades.md)
+ [Oracle Alert Log and PostgreSQL error log](chap-oracle-aurora-pg.configuration.errorlog.md)
+ [Oracle SGA and PGA memory sizing and PostgreSQL memory buffers](chap-oracle-aurora-pg.configuration.memory.md)
+ [Oracle instance parameters and Amazon RDS parameter groups](chap-oracle-aurora-pg.configuration.parameters.md)
+ [Oracle and PostgreSQL session parameters](chap-oracle-aurora-pg.configuration.session.md)

# Oracle and Aurora for PostgreSQL upgrades
<a name="chap-oracle-aurora-pg.configuration.upgrades"></a>

With AWS DMS, you can upgrade your Oracle and Aurora PostgreSQL databases to newer versions with minimal downtime. The Oracle and Aurora PostgreSQL upgrades feature facilitates seamless database upgrades by creating a new database instance with the desired version, migrating data from the old instance, and redirecting applications to the new instance. This capability is crucial for organizations that need to stay current with the latest database software releases for security, performance, and compatibility reasons.


| Feature compatibility |  AWS SCT / AWS DMS automation level |  AWS SCT action code index | Key differences | 
| --- | --- | --- | --- | 
|  N/A  |  N/A  |  N/A  |  N/A  | 

## Oracle usage
<a name="chap-oracle-aurora-pg.configuration.upgrades.ora"></a>

As a Database Administrator, from time to time a database upgrade is required, it can be either for security fix, but, or a new database feature.

The Oracle upgrades are divided into two different types of upgrades, minor and major.

This topic will outline the differences between the procedure to run upgrades on your Oracle databases today and how you will run those upgrades post migrating to Amazon RDS running Aurora.

The regular presentation of Oracle versions is combined of 4 numbers divided by dots (sometimes you will see the fifth number).

Either way, major or minor upgrades, the first step to initiate the processes mentioned above would be to install the new Oracle software on the database server, and of course before upgrading a production database to have an extensive amount of testing with the applications using the database to upgrade.

Oracle 18c introduces Zero-Downtime Database Upgrade to automate database upgrade and potentially eliminate application downtime during this process.

To understand the versions, let us use the following example 11.2.0.4.0.

These digits have the following meaning:
+ 11 — is the major database version.
+ 2 — is the database maintenance version.
+ 0 — application server version.
+ 4 — component specific version.
+ 0 — platform specific version.

For more information, see [About Oracle Database Release Numbers](https://docs.oracle.com/en/database/oracle/oracle-database/19/upgrd/oracle-database-release-numbers.html#GUID-1E2F3945-C0EE-4EB2-A933-8D1862D8ECE2) in the *Oracle documentation*.

In Oracle, the users can set the compatibility level of the database to control the features and some behaviors.

This is being done using the `COMPATIBLE` parameter, the value for this parameter can be fetched using the following query.

```
SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME = 'compatible';
```

## Upgrade process
<a name="chap-oracle-aurora-pg.configuration.upgrades.ora.process"></a>

In general, the process for major or minor upgrades is the same, minor version upgrade has less steps but overall the process is very similar.

Major upgrade referring to upgrades of the version number in the Oracle version, in the preceding example "11", the minor upgrade refers to any of the following numbers in the Oracle version, in the preceding example these will be "2.0.4.0".

Major upgrades are mostly being done in order to gain many new useful features being released between those versions, while minor upgrades are focused on bug and security fixes.

You can perform upgrades using the Oracle upgrade tools or manually.

Oracle tools will perform the following steps and might ask for some inputs or fixes from the user during the process.
+  **Upgrade operation type** — the user chooses either Oracle database upgrade or move database between Oracle software installations.
+  **Database selection** — the user selects the database to upgrade and the Oracle software to use for this database.
+  **Prerequisite checks** — Oracle tools will let the use choose what to do with all issues found and their severity.
+  **Upgrade options** — Oracle will let the use to pick his practices to do the upgrade, options such as recompilation and parallelism for those, time zone upgrade, statistics gathering, and more.
+  **Management options** — the user chooses to connect and configure Oracle management solutions to the database.
+  **Move database files** — the user chooses if a data file movement is required to a new devices or path.
+  **Network configuration** — Oracle listener configurations.
+  **Recovery options** — the user defines Oracle backup solutions or using his own.
+  **Summary** — a report of all options that were selected in previous steps to present before the upgrade.
+  **Progress** — monitor and present the upgrade status.
+  **Results** — a post upgrade summary.

For the manual process, we won’t cover all actions in this topic, as there are many steps and commands to run.

In overall, the preceding steps will be divided into many sub-steps and tasks to run.

For more information, see [Example of Manual Upgrade of Windows Non-CDB Oracle Database 11.2.0.3](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/upgrd/example-manual-upgrade-windows-non-cdb-11203-to-122.html#GUID-30F3DC9C-141A-47DC-9B83-6D0C395E565C) in the *Oracle documentation*.

## Aurora for PostgreSQL usage
<a name="chap-oracle-aurora-pg.configuration.upgrades.pg"></a>

After migrating your databases to Amazon RDS running Aurora for PostgreSQL, you will still need to upgrade your database instances from time to time, for the same reasons you have done in the past, new features, bugs and security fixes.

In a managed service such as Amazon RDS, the upgrade process is much easier and simpler compare to the on-prem Oracle process.

To determine the current Aurora for PostgreSQL version being used, you can use the following AWS CLI command.

```
aws rds describe-db-engine-versions
  --engine aurora-postgresql
  --query '*[].[EngineVersion]'
  --output text
  --region your-AWS-Region
```

This can also be queried from the database, using the following queries.

```
SELECT AURORA_VERSION();

aurora_version
4.0.0

SHOW SERVER_VERSION;

server_version
12.4
```

For Aurora and PostgreSQL versions mapping, see [Amazon Aurora PostgreSQL releases and engine versions](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.20180305.html) in the *Amazon RDS user guide*.

 AWS doesn’t apply major version upgrades on Amazon RDS and Aurora automatically. Major version upgrades contain new features and functionality which often involves system table and other code changes. These changes may not be backward-compatible with previous versions of the database so application testing is highly recommended.

Applying automatic minor upgrades can be set by configuring the Amazon RDS instance to allow it.

You can use the following AWS CLI command on Linux to determine the current automatic upgrade minor versions.

```
aws rds describe-db-engine-versions
  --engine aurora-postgresql
  | grep -A 1 AutoUpgrade
  | grep -A 2 true
  | grep PostgreSQL
  | sort --unique
  | sed -e 's/"Description":"//g'
```

If no results are returned, there is no automatic minor version upgrade available and scheduled.

When enabled, the instance will be automatically upgraded during the scheduled maintenance window.

For major upgrades, this is the recommended process:
+ Have a version-compatible parameter group ready. If you are using a custom DB instance or DB cluster parameter group, you have two options:
  + Specify the default DB instance, DB cluster parameter group, or both for the new DB engine version.
  + Create your own custom parameter group for the new DB engine version.

    If you associate a new DB instance or DB cluster parameter group as a part of the upgrade request, make sure to reboot the database after the upgrade completes to apply the parameters. If a DB instance needs to be rebooted to apply the parameter group changes, the instance’s parameter group status shows pending-reboot. You can view an instance’s parameter group status in the console or by using a CLI command such as `describe-db-instances` or `describe-db-clusters`.
+ Check for unsupported usage.
  + Commit or roll back all open prepared transactions before attempting an upgrade. You can use the following query to verify that there are no open prepared transactions on your instance

    ```
    SELECT count(*) FROM pg_catalog.pg_prepared_xacts;
    ```
  + Remove all uses of the `reg*` data types before attempting an upgrade. Except for `regtype` and `regclass`, you can’t upgrade the `reg*` data types. The `pg_upgrade` utility can’t persist this data type, which is used by Amazon Aurora to do the upgrade. To verify that there are no uses of unsupported `reg*` data types, use the following query for each database.

    ```
    SELECT count(*)
      FROM pg_catalog.pg_class c,
      pg_catalog.pg_namespace n,
      pg_catalog.pg_attribute a
        WHERE c.oid = a.attrelid
        AND NOT a.attisdropped
        AND a.atttypid IN ('pg_catalog.regproc'::pg_catalog.regtype,
          'pg_catalog.regprocedure'::pg_catalog.regtype,
          'pg_catalog.regoper'::pg_catalog.regtype,
          'pg_catalog.regoperator'::pg_catalog.regtype,
          'pg_catalog.regconfig'::pg_catalog.regtype,
          'pg_catalog.regdictionary'::pg_catalog.regtype)
        AND c.relnamespace = n.oid
        AND n.nspname NOT IN ('pg_catalog', 'information_schema');
    ```
+ Perform a backup. The upgrade process creates a DB cluster snapshot of your DB cluster during upgrading. If you also want to do a manual backup before the upgrade process.
+ Upgrade `pgRouting` and `postGIS` extensions to the latest available version before performing the major version upgrade. Run the following command for each extension that you use.

  ```
  ALTER EXTENSION PostgreSQL-extension UPDATE TO 'new-version'
  ```

An upgrade from versions older than 12, requires additional steps. For more information, see [Upgrading the PostgreSQL DB engine for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.PostgreSQL.html) in the *Amazon RDS user guide*.

After meeting all preceding prerequisites, you can perform the actual upgrade through the AWS console or AWS CLI.

 ** AWS Console** 

1. Sign in to your AWS console and choose **RDS**.

1. Choose **Databases** and select the database cluster that you want to upgrade.

1. Choose **Modify**.

1. For **DB engine version**, choose the new version.

1. Choose **Continue** and check the summary of modifications.

1. To apply the changes immediately, choose **Apply immediately**. Choosing this option can cause an outage in some cases. For more information, see [Modifying an Amazon Aurora DB cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Modifying.html) in the *Amazon RDS user guide*.

1. On the confirmation page, review your changes. If they are correct, choose **Modify cluster** to save your changes. Or choose **Back** to edit your changes or **Cancel** to cancel your changes.

 ** AWS CLI** 

For Linux, macOS, or Unix, use the following query.

```
aws rds modify-db-cluster \
  --db-cluster-identifier mydbcluster \
  --engine-version new_version \
  --allow-major-version-upgrade \
  --no-apply-immediately
```

For Windows, use the following query.

```
aws rds modify-db-cluster ^
  --db-cluster-identifier mydbcluster ^
  --engine-version new_version ^
  --allow-major-version-upgrade ^
  --no-apply-immediately
```

## Summary
<a name="chap-oracle-aurora-pg.configuration.upgrades.summary"></a>


| Phase | Oracle Step |  Aurora for PostgreSQL | 
| --- | --- | --- | 
|  Prerequisite  |  Install new Oracle software  |  N/A  | 
|  Prerequisite  |  Upgrade operation type  |  N/A  | 
|  Prerequisite  |  Database selection  |  Select the right Amazon RDS instance  | 
|  Prerequisite  |  Prerequisite checks  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/chap-oracle-aurora-pg.configuration.upgrades.html) <pre>SELECT count(*) FROM pg_catalog.pg_prepared_xacts;</pre>  | 
|  Prerequisite  |  Upgrade options  |  N/A  | 
|  Prerequisite  |  Management options (optional)  |  N/A  | 
|  Prerequisite  |  Move database files (optional)  |  N/A  | 
|  Prerequisite  |  Network configuration (optional)  |  N/A  | 
|  Prerequisite  |  Recovery options  |  N/A  | 
|  Prerequisite  |  Summary  |  N/A  | 
|  Prerequisite  |  Perform a database backup  |  Run Amazon RDS instance backup  | 
|  Prerequisite  |  Stop application and connection  |  Same  | 
|  Run  |  Progress  |  Review status from the console  | 
|  Post-upgrade  |  Results  |  Review status from the console  | 
|  Post-upgrade  |  Test applications against the new upgraded database  |  Same  | 
|  Production deployment  |  Re-run all steps in a production environment  |  Same  | 

For more information, see [Upgrading the PostgreSQL DB engine for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_UpgradeDBInstance.PostgreSQL.html) in the *Amazon RDS user guide*.

# Oracle Alert Log and PostgreSQL error log
<a name="chap-oracle-aurora-pg.configuration.errorlog"></a>

With AWS DMS, you can capture and analyze database logs to monitor migration tasks and troubleshoot issues. The Oracle Alert Log and PostgreSQL error log provide detailed information about database events, errors, and warnings during the migration process.


| Feature compatibility |  AWS SCT / AWS DMS automation level |  AWS SCT action code index | Key differences | 
| --- | --- | --- | --- | 
|   ![\[One star feature compatibility\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-compatibility-1.png)   |  N/A  |  N/A  |  Use [Event Notifications Subscription](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.html) with [Amazon Simple Notification Service](https://aws.amazon.com/sns).  | 

## Oracle usage
<a name="chap-oracle-aurora-pg.configuration.errorlog.ora"></a>

The primary Oracle error log file is the Alert Log. It contains verbose information about database activity including informational messages and errors. Each event includes a timestamp indicating when the event occurred. The Alert Log filename format is `alert<sid>.log`.

The Alert Log is the first place to look when troubleshooting or investigating errors, failures, and other messages indicating a potential database problem. Common events logged in the Alert Log include:
+ Database startup or shutdown.
+ Database redo log switch.
+ Database errors and warnings, which begin with `ORA-` followed by an Oracle error number.
+ Network and connection issues.
+ Links for a detailed trace files about specific database events.

The Oracle Alert Log can be found inside the database Automatic Diagnostics Repository (ADR), which is a hierarchical file-based repository for diagnostic information: `$ADR_BASE/diag/rdbms/{DB-name}/{SID}/trace`.

In addition, several other Oracle server components have unique log files such as the database listener and the Automatic Storage Manager (ASM).

 **Examples** 

The following screenshot displays partial contents of the Oracle database Alert Log File.

![\[Contents of the Oracle database Alert Log File\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-oracle-database-alert-log-file.png)


For more information, see [Monitoring Errors and Alerts](https://docs.oracle.com/en/database/oracle/oracle-database/19/admin/monitoring-the-database.html#GUID-E5F89E8E-7FBC-47DD-BA5D-96AFD9CE4BC7) in the *Oracle documentation*.

## PostgreSQL usage
<a name="chap-oracle-aurora-pg.configuration.errorlog.pg"></a>

PostgreSQL provides detailed logging and reporting of errors that occur during the database and connected sessions lifecycle. In an Amazon Aurora deployment, these informational and error messages are accessible using the Amazon RDS console.

### PostgreSQL and Oracle error codes
<a name="chap-oracle-aurora-pg.configuration.errorlog.pg.codes"></a>


| Oracle | PostgreSQL | 
| --- | --- | 
|  ORA-00001: unique constraint (string.string) violated  |  SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "constraint\$1name"  | 

For more information, see [PostgreSQL Error Codes](https://www.postgresql.org/docs/10/errcodes-appendix.html) in the *PostgreSQL documentation*.

### PostgreSQL error log types
<a name="chap-oracle-aurora-pg.configuration.errorlog.pg.types"></a>


| Log type | Information written to log | 
| --- | --- | 
|  DEBUG1…DEBUG5  |  Provides successively-more-detailed information for use by developers  | 
|  INFO  |  Provides information implicitly requested by the user  | 
|  NOTICE  |  Provides information that might be helpful to users  | 
|  WARNING  |  Provides warnings of likely problems  | 
|  ERROR  |  Reports an error that caused the current command to abort  | 
|  LOG  |  Reports information of interest to administrators  | 
|  FATAL  |  Reports an error that caused the current session to abort  | 
|  PANIC  |  Reports an error that caused all database sessions to abort  | 

For more information, see [Error Reporting and Logging](https://www.postgresql.org/docs/13/runtime-config-logging.html) in the *PostgreSQL documentation*.

 **Examples** 

Access the PostgreSQL error log using the Amazon RDS or Aurora management console.

1. Sign in to your AWS console and choose **RDS**.

1. Choose **Databases** and select your database.

1. Choose **Logs & events**.

    ![\[Logs and events tab\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-logs-events.png) 

1. Scroll down to the Logs section and select the log to inspect. For example, select the log during the hour the data was experiencing problems. The following screen shot displays partial contents of a PostgreSQL database error log as viewed from the Amazon RDS Management Console.

    ![\[Logs\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-logs.png) 

1. Choose one of the logs.

    ![\[View log\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-view-log.png) 

### PostgreSQL error log configuration
<a name="chap-oracle-aurora-pg.configuration.errorlog.pg.conf"></a>

The following tables shows parameters that control how and where PostgreSQL log and errors files will be placed.


| Parameter | Description | 
| --- | --- | 
|   `log_filename`   |  Sets the file name pattern for log files. Modifiable by an Aurora Database Parameter Group.  | 
|   `log_rotation_age`   |  (min) Automatic log file rotation will occur after N minutes. Modifiable by an Aurora Database Parameter Group.  | 
|   `log_rotation_size`   |  (kB) Automatic log file rotation will occur after N kilobytes. Modifiable by an Aurora Database Parameter Group.  | 
|   `log_min_messages`   |  Sets the message levels that are logged (`DEBUG`, `ERROR`, `INFO`, and so on). Modifiable by an Aurora Database Parameter Group  | 
|   `log_min_error_statement`   |  Causes all statements generating error at or above this level to be logged (`DEBUG`, `ERROR`, `INFO`, and so on). Modifiable by an Aurora Database Parameter Group.  | 
|   `log_min_duration_statement`   |  Sets the minimum run time above which statements will be logged (ms). Modifiable by an Aurora Database Parameter Group  | 

Modifications to certain parameters, such as `log_directory` (which sets the destination directory for log files) or `logging_collector` (which start a subprocess to capture stderr output and/or csvlogs into log files) are disabled for Aurora PostgreSQL instances.

# Oracle SGA and PGA memory sizing and PostgreSQL memory buffers
<a name="chap-oracle-aurora-pg.configuration.memory"></a>

With AWS DMS, you can optimize database performance by properly sizing memory components like Oracle’s System Global Area (SGA) and Program Global Area (PGA), as well as PostgreSQL’s memory buffers.


| Feature compatibility |  AWS SCT / AWS DMS automation level |  AWS SCT action code index | Key differences | 
| --- | --- | --- | --- | 
|   ![\[Two star feature compatibility\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-compatibility-2.png)   |  N/A  |  N/A  |  Different cache names, similar usage  | 

## Oracle usage
<a name="chap-oracle-aurora-pg.configuration.memory.ora"></a>

An Oracle instance allocates several individual “pools” of server RAM used as various caches for the database. These include the Buffer Cache, Redo Buffer, Java Pool, Shared Pool, Large Pool, and others. The caches reside in the System Global Area (SGA) and are shared across all Oracle sessions.

In addition to the SGA, each Oracle session is granted an additional area of memory for session-private operations (sorting, private SQL cursors elements, and so on) called the Private Global Area (PGA).

Cache size can be controlled for individual caches or globally, and automatically, by an Oracle database. Setting a unified “memory size” parameter enables Oracle to automatically manage individual cache sizes.
+ All Oracle memory parameters are set using the `ALTER SYSTEM` command.
+ Some changes to memory parameters require an instance restart.

Some of the common Oracle parameters that control memory allocations include:
+  `db_cache_size` — The size of the cache used for database data.
+  `log_buffer` — The cache used to store Oracle redo log buffers until they are written to disk.
+  `shared_pool_size` — The cache used to store shared cursors, stored procedures, control structures, and other structures.
+  `large_pool_size` — The cache used for parallel queries and RMAN backup/restore operations.
+  `Java_pool_size` — The cache used to store Java code and JVM context.

While these parameters can be configured individually, most database administrators choose to let Oracle automatically manage RAM. Database administrators configure the overall size of the SGA, and Oracle sizes individual caches based on workload characteristics.
+  `sga_max_size` — Specifies the hard-limit maximum size of the SGA.
+  `sga_target` — Sets the required soft-limit for the SGA and the individual caches within it.

Oracle also allows control over how much private memory is dedicated for each session. Database Administrators configure the total size of memory available for all connecting sessions, and Oracle allocates individual dedicated chunks from the total amount of available memory for each session.
+  `pga_aggregate_target` — A soft-limit controlling the total amount of memory available for all sessions combined.
+  `pga_aggregate_limit` — A hard-limit for the total amount of memory available for all sessions combined (Oracle 12c only).

In addition, instead of manually configuring the SGA and PGA memory areas, you can also configure one overall memory limit for both the SGA and PGA and let Oracle automatically balance memory between the various memory pools. This behavior is enabled using the `memory_target` and `memory_max_target` parameters.

For more information, see [Memory Architecture](https://docs.oracle.com/en/database/oracle/oracle-database/19/cncpt/memory-architecture.html#GUID-913335DF-050A-479A-A653-68A064DCCA41) and [Database Memory Allocation](https://docs.oracle.com/en/database/oracle/oracle-database/19/tgdba/database-memory-allocation.html#GUID-E9265077-B296-485A-BC2C-0AF55762D1EC) in the *Oracle documentation*.

## PostgreSQL usage
<a name="chap-oracle-aurora-pg.configuration.memory.pg"></a>

PostgreSQL provides us with control over how server RAM is allocated. The following table includes some of the most important PostgreSQL memory parameters.


| Memory pool parameter | Description | 
| --- | --- | 
|   `shared_buffers`   |  Used to cache database data read from disk. Approximate Oracle Database Buffer Cache equivalent.  | 
|   `wal_buffers`   |  Used to store WAL (Write-Ahead-Log) records before they are written to disk. Approximate Oracle Redo Log Buffer equivalent.  | 
|   `work_mem`   |  Used for parallel queries and SQL sort operations. Approximate Oracle PGA equivalent and/or the Large Pool (for parallel workloads).  | 
|   `maintenance_work_mem`   |  Memory used for certain backend database operations such as `VACUUM`, `CREATE INDEX`, `ALTER TABLE ADD FOREIGN KEY`.  | 
|   `temp_buffers`   |  Memory buffers used by each database session for reading data from temporary tables.  | 
|  Total memory available for PostgreSQL cluster  |  Controlled by choosing the **DB Instance Class** during instance creation.  ![\[Instance creation\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-db-instance-class.png)   | 

Cluster level parameters, such as `shared_buffers` and `wal_buffers`, are configured using parameter groups in the Amazon RDS Management Console.

 **Examples** 

View the configured values for database parameters.

```
show shared_buffers

show work_mem

show temp_buffers
```

View the configured values for all database parameters.

```
select * from pg_settings;
```

Use of the `SET SESSION` command to modify the value of parameters that support session-specific settings. Changing the value using the `SET SESSION` command for one session will have no effect on other sessions.

```
SET SESSION work_mem='100MB';
```

If a `SET SESSION` command is issued within a transaction that is aborted or rolled back, the effects of the `SET SESSION` command disappear. Once the transaction is committed, the effects will become persistent until the end of the session, unless overridden by another execution of `SET SESSION`.

Use of the `SET LOCAL` command to modify the current value of those parameters that can be set locally to a single transaction. Changing the value using the `SET LOCAL` command for one transaction will have no subsequent effect on other transactions from the same session. After issuing a `COMMIT` or `ROLLBACK`, the session-level settings will take effect.

```
SET LOCAL work_mem='100MB';
```

Reset a value of a run-time parameter to its default value.

```
RESET work_mem;
```

Changing parameter values can also be done with a direct update to the `pg_settings` table.

```
UPDATE pg_settings SET setting = '100MB' WHERE name = 'work_mem';
```

## Summary
<a name="chap-oracle-aurora-pg.configuration.memory.summary"></a>

Use the following table as a general reference only. Functionality may not be identical across Oracle and PostgreSQL.


| Description | Oracle | PostgreSQL | 
| --- | --- | --- | 
|  Memory for caching table data  |  db\$1cache\$1size  |  shared\$1buffers  | 
|  Memory for transaction log records  |  log\$1buffer  |  wal\$1buffers  | 
|  Memory for parallel queries  |  large\$1pool\$1size  |  work\$1mem  | 
|  Java code and JVM  |  Java\$1pool\$1size  |  N/A  | 
|  Maximum amount of physical memory available for the instance  |  sga\$1max\$1size or memory\$1max\$1size  |  Configured by the Amazon RDS/Aurora instance class For example: <pre>db.r3.large: 15.25GB<br />db.r3.xlarge: 30.5GB</pre>  | 
|  Total amount of private memory for all sessions  |  pga\$1aggregate\$1target and pga\$1aggregate\$1limit  |  temp\$1buffers (for reading data from temp tables), work\$1mem (for sorts)  | 
|  View values for all database parameters  |  <pre>SELECT * FROM v$parameter;</pre>  |  <pre>Select * from pg_settings;</pre>  | 
|  Configure a session-level parameter  |  <pre>ALTER SESSION SET ...</pre>  |  <pre>SET SESSION ...</pre>  | 
|  Configure instance-level parameter  |  <pre>ALTER SYSTEM SET ...</pre>  |  Configured by parameter groups in the Amazon RDS Management Console.  | 

For more information, see [Write Ahead Log](https://www.postgresql.org/docs/13/runtime-config-wal.html) and [Resource Consumption](https://www.postgresql.org/docs/13/runtime-config-resource.html) in the *PostgreSQL documentation*.

# Oracle instance parameters and Amazon RDS parameter groups
<a name="chap-oracle-aurora-pg.configuration.parameters"></a>

With AWS DMS, you can configure Oracle instance parameters and Amazon RDS parameter groups to optimize database performance, security, and resource utilization. Oracle instance parameters control various aspects of an Oracle database instance, such as memory allocation, logging, and backup settings. Amazon RDS parameter groups act as a container for engine configuration values that can be applied to one or more Amazon RDS database instances.


| Feature compatibility |  AWS SCT / AWS DMS automation level |  AWS SCT action code index | Key differences | 
| --- | --- | --- | --- | 
|   ![\[One star feature compatibility\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-compatibility-1.png)   |  N/A  |  N/A  |  Use Cluster and Database/Cluster parameters.  | 

## Oracle usage
<a name="chap-oracle-aurora-pg.configuration.parameters.ora"></a>

Oracle instance and database-level parameters can be configured using the `ALTER SYSTEM` command. Certain parameters can be configured dynamically and take immediate effect while other parameters require an instance restart.
+ All Oracle instance and database-level parameters are stored in a binary file known as the Server Parameter file (SPFILE).
+ The binary SPFILE can be exported to a text file using the following command:

  ```
  CREATE PFILE = 'my_init.ora' FROM SPFILE = 's_params.ora';
  ```

When modifying parameters, you can choose the persistence of the changed values with one of the three following options:
+ Make the change applicable only after a restart by specifying `scope=spfile`.
+ Make the change dynamically, but not persistent, after a restart by specifying `scope=memory`.
+ Make the change both dynamically and persistent by specifying `scope=both`.

 **Examples** 

Use the `ALTER SYSTEM SET` command to configure a value for an Oracle parameter.

```
ALTER SYSTEM SET QUERY_REWRITE_ENABLED = TRUE SCOPE=BOTH;
```

For more information, see [Initialization Parameters](https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/initialization-parameters-2.html#GUID-FD266F6F-D047-4EBB-8D96-B51B1DCA2D61) and [Changing Parameter Values in a Parameter File](https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/changing-parameter-values-in-a-parameter-file.html#GUID-4C578B21-DE2B-4210-8EB7-EF28D36CC1CB) in the *Oracle documentation*.

## PostgreSQL usage
<a name="chap-oracle-aurora-pg.configuration.parameters.pg"></a>

When running PostgreSQL databases as Amazon Aurora Clusters, Parameter Groups are used to change to cluster-level and database-level parameters.

Most of the PostgreSQL parameters are configurable in an Amazon Aurora PostgreSQL cluster, but some are disabled and can’t be modified. Since Amazon Aurora clusters restrict access to the underlying operating system, modification to PostgreSQL parameters must be made using Parameter Groups.

 Amazon Aurora is a cluster of database instances and, as a direct result, some of the PostgreSQL parameters apply to the entire cluster while other parameters apply only to a particular database instance.


|  Aurora PostgreSQL parameter class | Controlled by | 
| --- | --- | 
|   **Cluster-level parameters**  Single cluster parameter group for each Amazon Aurora cluster.  |  Managed by cluster parameter groups. For example, [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/chap-oracle-aurora-pg.configuration.parameters.html)  | 
|   **Database instance-level parameters**  Every instance in an Amazon Aurora cluster can be associated with a unique database parameter group.  |  Managed by database parameter groups For example, [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/chap-oracle-aurora-pg.configuration.parameters.html)  | 

PostgreSQL 10 introduces the following new parameters:
+  `enable_gathermerge` — enable run plan gather merge.
+  `max_parallel_workers` — maximum number of parallel workers process.
+  `max_sync_workers_per_subscription` — maximum number of synchronous workers for subscription.
+  `wal_consistency_checking` — check consistency of WAL on the standby instance (can’t be set in Aurora PostgreSQL).
+  `max_logical_replication_workers` — maximum number of logical replication worker process.
+  `max_pred_locks_per_relation` — Maximum number of records that can be predicate-lock before locking the entire relation (signup).
+  `max_pred_locks_per_page` — Maximum number of records that can be predicate-lock before locking the entire page.
+  `min_parallel_table_scan_size` — minimum table size to consider parallel table scan.
+  `min_parallel_index_scan_size` — minimum table size to consider parallel index scan.

 **Examples** 

Follow the following steps to create and configure Amazon Aurora database and cluster parameter groups.

1. Sign in to the AWS Management Console and choose **RDS**.

1. Choose **Parameter groups** and choose **Create parameter group**.

**Example**  
You can’t edit the default parameter group. Create a custom parameter group to apply changes to your Amazon Aurora cluster and its database instances.

1. For **Parameter group family**, choose the database family.

1. For **Type**, choose **DB Parameter Group**.

1. Choose **Create**.

Follow the following steps to modify an existing parameter group.

1. Sign in to the AWS Management Console and choose **RDS**.

1. Choose **Parameter groups** and choose the name of the parameter to edit.

1. For **Parameter group actions**, choose **Edit**.

1. Change parameter values and choose **Save changes**.

For more information, see [SET](https://www.postgresql.org/docs/13/sql-set.html) in the *PostgreSQL documentation*.

# Oracle and PostgreSQL session parameters
<a name="chap-oracle-aurora-pg.configuration.session"></a>

With AWS DMS, you can configure session parameters for Oracle and PostgreSQL databases to optimize performance and customize behavior during migration tasks. Session parameters are special configuration options that influence how the database engine operates and processes data.


| Feature compatibility |  AWS SCT / AWS DMS automation level |  AWS SCT action code index | Key differences | 
| --- | --- | --- | --- | 
|   ![\[One star feature compatibility\]](http://docs.aws.amazon.com/dms/latest/oracle-to-aurora-postgresql-migration-playbook/images/pb-compatibility-1.png)   |  N/A  |  N/A  |  SET options are significantly different in PostgreSQL.  | 

## Oracle usage
<a name="chap-oracle-aurora-pg.configuration.session.ora"></a>

Certain Oracle database parameters and configuration options are modifiable at the session level using the `ALTER SESSION` command. However, not all Oracle configuration options and parameters can be modified on a per-session basis. To view a list of all configurable parameters that can be set for the scope of a specific session, query the `v$parameter` view as shown in the following example.

```
SELECT NAME, VALUE FROM V$PARAMETER WHERE ISSES_MODIFIABLE='TRUE';
```

 **Examples** 

Change the `NLS_LANAUGE` codepage parameter of the current session.

```
alter session set nls_language='SPANISH'

Sesi≤n modificada.

alter session set nls_language='ENGLISH';

Session altered.

alter session set nls_language='FRENCH';

Session modifiΘe.

alter session set nls_language='GERMAN';

Session wurde geΣndert.
```

Specify the format of date values returned from the database using the `NLS_DATE_FORMAT` session parameter.

```
select sysdate from dual;

SYSDATE
SEP-09-17

alter session set nls_date_format='DD-MON-RR';

Session altered.

select sysdate from dual;

SYSDATE
09-SEP-17

alter session set nls_date_format='MM-DD-YYYY';

Session altered.

select sysdate from dual;

SYSDATE
09-09-2017

alter session set nls_date_format='DAY-MON-RR';

Session altered.
```

For more information, see [Changing Parameter Values in a Parameter File](https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/changing-parameter-values-in-a-parameter-file.html#GUID-4C578B21-DE2B-4210-8EB7-EF28D36CC1CB) in the *Oracle documentation*.

## PostgreSQL usage
<a name="chap-oracle-aurora-pg.configuration.session.pg"></a>

PostgreSQL provides session-modifiable parameters that are configured using the `SET SESSION` command. Configuration of parameters using `SET SESSION` will only be applicable in the current session. To view the list of parameters that can be set with `SET SESSION`, you can query `pg_settings`.

```
SELECT * FROM pg_settings where context = 'user';
```

Find the commonly used session parameters following:
+  `client_encoding` configures the connected client character set.
+  `force_parallel_mode` forces use of parallel query for the session.
+  `lock_timeout` sets the maximum allowed duration of time to wait for a database lock to release.
+  `search_path` sets the schema search order for object names that are not schema-qualified.
+  `transaction_isolation` sets the current Transaction Isolation Level for the session.

 **Examples** 

Change the Time zone of the connected session.

```
set session DateStyle to POSTGRES, DMY;
SET

select now();

now
Sat 09 Sep 11:03:43.597202 2017 UTC
(1 row)

set session DateStyle to ISO, MDY;
SET

select now();

now
2017-09-09 11:04:01.3859+00
(1 row)
```

## Summary
<a name="chap-oracle-aurora-pg.configuration.session.summary"></a>

The following table includes a partial list of parameters and is meant to highlight various session-level configuration parameters in both Oracle and PostgreSQL. Not all parameters are directly comparable.


| Parameter purpose | Oracle | PostgreSQL | 
| --- | --- | --- | 
|  Configure time and date format  |  <pre>ALTER SESSION<br />  SET nls_date_format =<br />    'dd/mm/yyyy hh24:mi:ss';</pre>  |  <pre>SET SESSION<br />  datestyle to 'SQL, DMY';</pre>  | 
|  Configure the current default schema or database  |  <pre>ALTER SESSION<br />  SET current schema='schema_name'</pre>  |  <pre>SET SESSION<br />  SEARCH_PATH TO schemaname;</pre>  | 
|  Generate traces for specific errors  |  <pre>ALTER SESSION SET<br />  events '10053 trace name<br />    context forever';</pre>  |  N/A  | 
|  Run trace for a SQL statement  |  <pre>ALTER SESSION<br />  SET sql_trace=TRUE;<br />ALTER SYSTEM<br />  SET EVENTS 'sql_trace<br />    [sql:&&sql_id]<br />    bindd=true, wait=true';</pre>  |  N/A  | 
|  Modify query optimizer cost for index access  |  <pre>ALTER SESSION<br />  SET optimizer_index_cost_adj = 50</pre>  |  <pre>SET SESSION random_page_cost TO 6;</pre>  | 
|  Modify query optimizer row access strategy  |  <pre>ALTER SESSION<br />  SET optimizer_mode=all_rows;</pre>  |  N/A  | 
|  Memory allocated to sort operations  |  <pre>ALTER SESSION<br />  SET sort_area_size=6321;</pre>  |  <pre>SET SESSION work_mem TO '6MB';</pre>  | 
|  Memory allocated to hash joins  |  <pre>ALTER SESSION<br />  SET hash_area_size=1048576000;</pre>  |  <pre>SET SESSION work_mem TO '6MB';</pre>  | 

For more information, see [SET](https://www.postgresql.org/docs/13/sql-set.html) in the *PostgreSQL documentation*.