This article has been rewritten and is now part of a 4-part series about cursor sharing.
Monday, April 29, 2024
Thursday, April 11, 2024
Configuring Shared Global Area (SGA) in a Multitenant Database with a PeopleSoft Pluggable Database (PDB)
I have been working on a PeopleSoft Financials application that we have converted from a stand-alone database to be the only pluggable database (PDB) in an Oracle 19c container database (CDB). We have been getting shared pool errors in the PDB that lead to ORA-4031 errors in the PeopleSoft application.
I have written a longer version of this article on my Oracle blog, but here are the main points.
SGA Management with a Parse Intensive System (PeopleSoft).
PeopleSoft systems dynamically generate lots of non-shareable SQL code. This leads to lots of parse and consumes more shared pool. ASMM can respond by shrinking the buffer cache and growing the shared pool. However, this can lead to more physical I/O and degrade performance and it is not beneficial for the database to cache dynamic SQL statements that are not going to be executed again. Other parse-intensive systems can also exhibit this behaviour.
In PeopleSoft, I normally set DB_CACHE_SIZE and SHARED_POOL_SIZE to minimum values to stop ASMM shuffling too far in either direction. With a large SGA, moving memory between these pools can become a performance problem in its own right.
We removed SHARED_POOL_SIZE, DB_CACHE_SIZE and SGA_MIN_SIZE settings from the PDB. The only SGA parameters set at PDB level are SGA_TARGET and INMEMORY_SIZE.
SHARED_POOL_SIZE and DB_CACHE_SIZE are set as I usually would for PeopleSoft, but at CDB level to guarantee a minimum buffer cache size.
This is straightforward when there is only one PDB in the CDB. I have yet to see what happens when I have another active PDB with a non-PeopleSoft system and a different kind of workload that puts less stress on the shared pool and more on the buffer cache.
Initialisation Parameters
- SGA_TARGET "specifies the total size of all SGA components". Use this parameter to control the memory usage of each PDB. The setting at CDB must be at least the sum of the settings for each PDB.
- Recommendations:
- Use only this parameter at PDB level to manage the memory consumption of the PDB.
- In a CDB with only a single PDB, set SGA_TARGET to the same value at CDB and PDB levels.
- Therefore, where there are multiple PDBs, SGA_TARGET at CDB level should be set to the sum of the setting for each PDB. However, I haven't tested this yet.
- There is no recommendation to reserve SGA for use by the CDB only, nor in my experience is there any need so to do.
- SHARED_POOL_SIZE sets the minimum amount of shared memory reserved to the shared pool. It can optionally be set in a PDB.
- Recommendation: However, do not set SHARED_POOL_SIZE at PDB level. It can be set at CDB level.
- DB_CACHE_SIZE sets the minimum amount of shared memory reserved to the buffer cache. It can optionally be set in a PDB.
- Recommendation: However, do not set DB_CACHE_SIZE at PDB level. It can be set at CDB level.
- SGA_MIN_SIZE has no effect at CDB level. It can be set at PDB level at up to half of the manageable SGA
- Recommendation: However, do not set SGA_MIN_SIZE.
- INMEMORY_SIZE: If you are using in-memory query, this must be set at CDB level in order to reserve memory for the in-memory store. The parameter defaults to 0, in which case in-memory query is not available. The in-memory pool is not managed by Automatic Shared Memory Management (ASMM), but it does count toward the total SGA used in SGA_TARGET.
- Recommendation: Therefore it must also be set in the PDB where in-memory is being used, otherwise we found(contrary to the documetntation) that the parameter defaults to 0, and in-memory query will be disabled in that PDB.
Oracle Notes
- A-04031 on Multitenant Database with Excessive Amounts of KGLH0 and / or SQLA Memory and Parameter SHARED_POOL_SIZE or SGA_MIN_SIZE Set at the PDB Level (Doc ID 2590172.1) – December 2022, Updated April 2023
- This one says “Remove the PDB-level SHARED_POOL_SIZE and/or SGA_MIN_SIZE initialization parameters. The only SGA memory sizing parameter that Oracle recommends setting at the PDB level is SGA_TARGET.”
- About memory configuration parameter on each PDBs (Doc ID 2655314.1) – Nov 2023
- “As a best practice, please do not to set SHARED_POOL_SIZE and DB_CACHE_SIZE on each PDBs and please manage automatically by setting SGA_TARGET.”
- "This best practice is confirmed by development in Bug 30692720"
- Bug 30692720 discusses how the parameters are validated. Eg. "Sum(PDB sga size) > CDB sga size"
- Bug 34079542: "Unset sga_min_size parameter in PDB."
Configuring Shared Global Area (SGA) in a Multitenant Database
I have been working on a PeopleSoft Financials application that we have converted from a stand-alone database to be the only pluggable database (PDB) in an Oracle 19c container database (CDB). We have been getting ORA-4031 (unable to allocate shared memory) errors in the PeopleSoft application.
It has taken a while to solve and test, and I have to acknowledge quite a lot of advice from my friends.
If you are wondering why you should be involved with your local Oracle user group, and regularly attend their meetings, this is an example: So you can ask people who have experience of different systems in different situations that you haven't encountered yet!
Documentation
I am going to look at 6 initialisation parameters that control the use of SGA. The Oracle documentation, even in 21c, suggests they can mostly be set at CDB and PDB levels. However, more recent Oracle guidance confirmed by my own experience suggests that is not a good idea.
- SGA_MAX_SIZE can only be set at CDB level. It sets the size of the shared memory segment that is the SGA. It cannot be changed during the life of the database instance.
- Recommendation:
- It can be useful to set it higher than SGA_TARGET if you plan either to increase SGA_TARGET, or add PDBs to the CDB, without restarting the instances.
- SGA_TARGET "specifies the total size of all SGA components". Use this parameter to control the memory usage of each PDB. The setting at CDB must be at least the sum of the settings for each PDB.
- Recommendations:
- Use only this parameter at PDB level to manage the memory consumption of the PDB.
- In a CDB with only a single PDB, set SGA_TARGET to the same value at CDB and PDB levels.
- Therefore, where there are multiple PDBs, SGA_TARGET at CDB level should be set to the sum of the settings for each PDB. However, I haven't tested this yet.
- There is no recommendation to reserve SGA for use by the CDB only, nor in my experience is there any need so to do.
- SHARED_POOL_SIZE sets the minimum amount of shared memory reserved to the shared pool. It can optionally be set in a PDB.
- Recommendation: However, do not set SHARED_POOL_SIZE at PDB level. It can be set at CDB level.
- DB_CACHE_SIZE sets the minimum amount of shared memory reserved to the buffer cache. It can optionally be set in a PDB.
- Recommendation: However, do not set DB_CACHE_SIZE at PDB level. It can be set at CDB level.
- SGA_MIN_SIZE has no effect at CDB level. It can be set at PDB level at up to half of the manageable SGA
- Recommendation: However, do not set SGA_MIN_SIZE.
- INMEMORY_SIZE: If you are using in-memory query, this must be set at CDB level in order to reserve memory for the in-memory store. The parameter defaults to 0, in which case in-memory query is not available. The in-memory pool is not managed by Automatic Shared Memory Management (ASMM), but it does count toward the total SGA used in SGA_TARGET.
- Recommendation: Therefore it must also be set in the PDB where in-memory is being used, otherwise we found (contrary to the documentation) that the parameter defaults to 0, and in-memory query will be disabled in that PDB.
Oracle Notes
There are a lot of Oracle support notes on the subject SGA management in a multi-tenant database. The older nodes talk about setting memory parameters in the PDB, and a later note and a bug advises only setting these parameters at CDB level, and not at all in the PDB.
- How to Control and Monitor the Memory Usage (Both SGA and PGA) Among the PDBs in Multitenant Database- 12.2 New Feature (Doc ID 2170772.1) – December 2018, updated July 2023
- This document discusses setting SGA_MIN_SIZE at PDB level.
- The diagrams tend to suggest that there is a requirement to reserve some memory for the CDB SGA, but it does not suggest how it might be done. Presumably by making sure the sum of SGA_TARGET for each PDB are less than SGA_TARGET at CDB level. The documentation states that SGA_MIN_SIZE has no effect at CDB level,
- How To Modify memory parameters On a Pluggable Database (PDB) (Doc ID 2706020.1) – September 2020 - Updated March 2024
- This note discusses setting SHARED_POOL_SIZE, DB_CACHE_SIZE, and MIN_SGA_SIZE
- How to Control the SGA Memory Usage Among the CDB/PDBs in Multitenant Database. (Doc ID 2712535.1) – September 2020, Updated April 2023
- This note discusses setting SHARED_POOL_SIZE, DB_CACHE_SIZE and SGA_MIN_SIZE at PDB level.
- ORA-04031 on Multitenant Database with Excessive Amounts of KGLH0 and / or SQLA Memory and Parameter SHARED_POOL_SIZE or SGA_MIN_SIZE Set at the PDB Level (Doc ID 2590172.1) – December 2022, Updated April 2023
- This one says “Remove the PDB-level SHARED_POOL_SIZE and/or SGA_MIN_SIZE initialization parameters. The only SGA memory sizing parameter that Oracle recommends setting at the PDB level is SGA_TARGET.”
- About memory configuration parameter on each PDBs (Doc ID 2655314.1) – November 2023
- “As a best practice, please do not to set SHARED_POOL_SIZE and DB_CACHE_SIZE on each PDBs and please manage automatically by setting SGA_TARGET.”
- "This best practice is confirmed by development in Bug 30692720"
- Bug 30692720 discusses how the parameters are validated. Eg. "Sum(PDB sga size) > CDB sga size"
- Bug 34079542: "Unset sga_min_size parameter in PDB."
SGA Management with a Parse Intensive System (PeopleSoft).
PeopleSoft systems dynamically generate lots of non-shareable SQL code. This leads to lots of parse and consumes more shared pool. ASMM can respond by shrinking the buffer cache and growing the shared pool. However, this can lead to more physical I/O and degrade performance and it is not beneficial for the database to cache dynamic SQL statements that are not going to be executed again. Other parse-intensive systems can also exhibit this behaviour.
In PeopleSoft, I normally set DB_CACHE_SIZE and SHARED_POOL_SIZE to minimum values to stop ASMM shuffling too far in either direction. With a large SGA, moving memory between these pools can become a performance problem in its own right.
We removed SHARED_POOL_SIZE, DB_CACHE_SIZE and SGA_MIN_SIZE settings from the PDB. The only SGA parameters set at PDB level are SGA_TARGET and INMEMORY_SIZE. We have found it is safe to reduce the setting of SGA_TARGET at PDB level, but reducing at CDB level without also restarting the instance has caused problems.
SHARED_POOL_SIZE and DB_CACHE_SIZE are set as I usually would for PeopleSoft, but only at CDB level to guarantee a minimum buffer cache size.
This is straightforward when there is only one PDB in the CDB. I have yet to see what happens when I have another active PDB with a non-PeopleSoft system and a different kind of workload that puts less stress on the shared pool and more on the buffer cache.
TL;DR
- Do not set any SGA parameter in a PDB other than SGA_TARGET and (if necessary) INMEMORY_SIZE.
- Do not set DB_CACHE_SIZE, SHARED_POOL_SIZE at PDB level. They can be set at CDB level.
- Do not set SGA_MIN_SIZE at either PDB or CDB level.
Monday, March 11, 2024
PSFT_PLAN: A Sample Oracle Database Resource Manager Plan for PeopleSoft
- If you never run out of CPU, then you have probably bought/rented/allocated/licensed too many CPUs.
- If you do run out of CPU, then you should use the database resource manager to prioritise the processes that are most important to the business.
- If you don't enable the resource manager, you will have less visibility of when you do run out of CPU.
- See also Go-Faster Blog: More Bang for your Buck in the Cloud with Resource Manager
Resource Plan Design Goals
Consumer Groups
| Priority Level | Consumer Group | %CPU Guarantee | Comment |
|---|---|---|---|
| 1 | SYS _GROUP | 100% | Oracle system processes. Defined automatically. |
| 2 | PSFT _GROUP | 100% |
Any process that connects to the database as either SYSADM (the default
PeopleSoft owner ID) or PS has higher priority than other processes unless other rules apply. The online application (other than ad hoc query) falls into this category so that the online user experience is safeguarded before other PeopleSoft processes. This includes remote call Cobol processes, but not remote call Application Engine that should be run in the component processor. |
| 4 | BATCH _GROUP | 100% | Process scheduler processes, and processes run by the process schedulers |
| 5 | NVISION _GROUP | 100% | nVision (NVSRUN) and nVision report book (RPTBOOK) processes |
| 6 | PSQUERY _ONLINE _GROUP | 90% | Ad hoc queries are allocated to one of three consumer groups with the same priority, but different CPU guarantees, comprising:
|
| PSQUERY _BATCH _GROUP | 9% |
| |
| NVSRUN _GROUP | 1% |
| |
| 8 | LOW _GROUP | 1% | Other low-priority processes |
| LOW _LIMITED _GROUP | 1% | Other low-priority processes, but whose maximum query time is limited. | |
| OTHER _GROUPS | 1% | All other processes. Defined automatically. |
Consumer Group Mapping Priority
| Priority | Mapping Attribute | Comment |
|---|---|---|
| 2 | Module, Action | The PIA instrumentation sets attributes MODULE to the component name and ACTION to the page name. Specific component pages are allocated to specific consumer groups |
| 3 | Module | Specific scheduled processes are allocated by name to specific consumer groups. PeopleSoft instrumentation puts this name in the MODULE attribute. |
| 4 | Client Program | Batch and query processes are identified by program name and allocated to certain consumer groups. |
| 5 | Oracle User | Anything that connects to the database as either SYSADM or PS is allocated to the PSFT_GROUP. So other mapping rules must take precedence over this mapping. |
Required PeopleSoft Configuration
- Enable PeopleSoft instrumentation: Set EnableAEMonitoring=1 in ALL PeopleSoft application server and process scheduler domains so that PeopleSoft processes set MODULE and ACTION information in the session attributes (using DBMS_APPLICATION_INFO).
See also:
- PeopleTools PeopleBooks: Administration Tools -> Data Management -> Administering PeopleSoft Databases on Oracle -> Monitoring PeopleSoft MODULE and ACTION Information, Press Enter to collapse
- PeopleSoft DBA Blog: Undocumented (until PeopleTools 8.55) Application Engine Parameter: EnableAEMonitoring
- PeopleSoft DBA Blog: PeopleTools 8.50 uses DBMS_APPLICATION_INFO to Identify Database Sessions
- Go-Faster Blog: One of my Favourite Database Things: DBMS_APPLICATION_INFO
- Install instrumentation trigger for PeopleSoft (psftapi.sql). Not all PeopleSoft processes are instrumented. COBOL, SQR, and nVision do not set MODULE or ACTION. When a PeopleSoft process is started by the process scheduler, the first thing it does is set its own status to 7, meaning that it is processing. This script creates a database trigger that fires on that DML and sets the session attributes MODULE to the name of the process and ACTION to the process instance number. Application Engine processes may then subsequently update these values again.
Consumer Group Mappings
| Mapping Priority | Attribute | Value | Consumer Group Priority |
Consumer Group |
|---|---|---|---|---|
| 2 | MODULE_ACTION | QUERY_MANAGER.QUERY_VIEWER | 6 | PSQUERY_ONLINE_GROUP |
| 3 | MODULE | RPTBOOK NVSRUN | 5 | NVISION_GROUP |
| PSQRYSRV% | 6 | PSQUERY_ONLINE_GROUP | ||
| PSAE.PSQUERY.% | 6 | PSQUERY_BATCH_GROUP | ||
| 4 | CLIENT_PROGRAM | PSRUNRMT | 2 | PSFT_GROUP |
| psae% PSAESRV% PSDSTSRV% PSMSTPRC% PSRUN@% PSSQR% pssqr% sqr% | 4 | BATCH_GROUP | ||
| PSQRYSRV% | 6 | PSQUERY_ONLINE_GROUP | ||
| PSNVSSRV% | 6 | NVSRUN_GROUP | ||
| SQL Developer sqlplus% Toad% | 8 | LOW_GROUP / LOW_LIMITED_GROUP | ||
| 5 | ORACLE_USER | PS SYSADM | 2 | PSFT_GROUP |
Resource Plan Script
- psft_resource_plan_simple.sql creates the resource plan. This is intended to be a starting point to which either unwanted parts can be removed, or additional requirements can be added
- resource_plan_report.sql reports on all the resource plan metadata.
Other Options
There are other resource manager options that are either not illustrated in the sample plan, or that are commented out. They may be worth considering in some situations.
- PeopleSoft does not use parallel query by default, but if you do use it, you may well want to limit which processes use how much parallelism. Consumer groups can specify a limit to the parallel query degree.
- If you use the resource plan to restrict the degree of parallelism, and you also plan to vary the number of CPUs in a cloud environment, then I suggest creating a resource plan for each number of CPUs and switch between the plans by changing the setting of the RESOURCE_MANAGER_PLAN parameter.
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'NVISION_GROUP', 'nVision Reports.'
,mgmt_p5 => 100
,parallel_degree_limit_p1=>2
);
- A parallel query may queue waiting to obtain sufficient parallel query server processes. A timeout can be specified to limit that wait and to determine the behaviour when the timeout is reached. The query can either be cancelled raising error ORA-07454, or run at a reduced parallelism).
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'PSQUERY_ONLINE_GROUP'
,mgmt_p6 => 90
,parallel_queue_timeout=>900
,pq_timeout_action=>'RUN'
);
- A consumer group can restrict queries that run for a long time, or that are expected to run for a long time based on their optimizer cost. They can be switched to the CANCEL_SQL group after a number of seconds and they will terminate with ORA-00040: active time limit exceeded - call aborted:. This has only specified for the LOW_LIMITED_GROUP, and the PSQUERY_BATCH_GROUP for scheduled queries because the message is captured by the process scheduler and logged. It has not been specified for PSQUERY_ONLINE_GROUP because this error is not handled well by the online application. Just the Oracle error message will be displayed to the user without further explanation, which is neither friendly nor helpful. Instead, there are PeopleSoft configuration options to limit query runtime.
DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE(
'PSFT_PLAN', 'PSQUERY_BATCH_GROUP'
,mgmt_p6 => 1
,switch_group => 'CANCEL_SQL'
,switch_time => 14400
,switch_estimate => TRUE
,switch_for_call => TRUE
);
- Sometimes customers may have different priorities at different times that cannot be satisfied by a single resource plan. In this case, different resource plans can be activated at different times by different scheduler windows.
Other Online Resources
- Oracle White Paper: Using Oracle Database ResourceManager
- Documentation: Oracle Resource Manager Enhancements in Oracle Database 10g
- Documentation: Oracle Resource Manager Enhancements in Oracle Database 12c Release 1 (12.1)
Thursday, February 22, 2024
Table Clusters: 6. Testing the Cluster & Conclusion (TL;DR)
This post is the last part of a series that discusses table clustering in Oracle.
- Introduction and Ancient History
- Cluster & Cluster Key Design Considerations
- Populating the Cluster with DBMS_PARALLEL_EXECUTE
- Checking the Cluster Key
- Using the Cluster Key Index instead of the Primary/Unique Key Index
- Testing the Cluster & Conclusion (TL;DR)
Testing
We did get improved performance with the clustered tables. More significantly, we encountered less inter-process contention, and so were able to run more concurrent processes, and the overall elapsed time of all the processes was reduced.
Looking at just the performance of the bulk delete statements on the result tables, there is a significant reduction in DB time and physical I/O time on the clustered tables. The reduction in physical I/O is not only because the table is smaller, but because there is no need to perform consistent read recovery on the blocks, there are fewer reads from the undo segment and less CPU was consumed creating consistent read copies in the buffer cache.
| Statement | Heap Table | Clustered Table | |
| DELETE FROM PS_GP_RSLT_ACUM… | |||
| DB Time (s) | 2182 |
1662 | |
| delete statement only | db file sequential | 1451 |
891 |
| CPU | 941 |
531 | |
| Statement | Heap Table | Clustered Table | |
| DELETE FROM PS_GP_RSLT_ABS… | |||
| DB Time (s) | 781 |
330 | |
| delete statement only | db file sequential | 340 |
210 |
| CPU | 300 | 120 | |
Statement |
Heap Table | Heap in Cluster Test | |
| DELETE FROM PS_GP_RSLT_PIN… | |||
| DB Time (s) | 270 |
250 | |
| delete statement only | db file sequential | 110 |
120 |
| CPU | 110 |
90 | |