Customizing SQL.BSQ

本文提供了一套策略来防止数据库创建时的系统表空间碎片化,包括选择合适的表空间管理策略、调整sql.bsq文件以优化物理存储、确保足够的空间用于回滚段,并通过二次数据库创建过程进行精细化调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.ixora.com.au/tips/creation/bsq.htm

Most DBAs are reluctant to customize the sql.bsq file prior to database creation, in the belief that doing so is unsupported.However, since release 7.3, limited customization of the sql.bsq file has been supported.You may still see comments to the contrary, even from within Oracle.However, the Tuning guide of the official Oracle documentation setallows that modifications may be made to the sql.bsq file to optimize the physical storage of the data dictionary.You may not, however, modify the logical structure of the data dictionary.

We strongly recommend that you take the opportunity to customize the sql.bsq fileprior to the creation of any performance critical database.A failure to do so will introduce problems that can only be repaired by recreating the database.But before you can make your changes to sql.bsq, you need to consider to the following question.

How can you prevent fragmentation of the SYSTEM tablespace?

The control of space within the SYSTEM tablespace is particularly difficult because it is used in diverse and mysterious ways.However, of all tablespaces the SYSTEM tablespace is the most important one in which to avoid fragmentation,because repairing such damage normally involves rebuilding the database.

I scarcely need repeat the cardinal rule that other than the data dictionarynothing should be allowed in the SYSTEM tablespace that can possibly go elsewhere.In particular, no user, other than SYS, should have SYSTEM as their DEFAULT TABLESPACE.And no user, not even SYS, should have SYSTEM as their TEMPORARY TABLESPACE.You can use the APT script system_space_invaders.sql to identify any such users.

Despite all such warnings, the creation of extraneous segments in the SYSTEM tablespaceis still the main cause of SYSTEM tablespace fragmentation.Scripts such as Oracle's utlbstat.sql and utlestat.sqlthat create and drop segments in the SYS schema's default tablespace don't help.

Of course, there are some things that go into the SYSTEM tablespace that you cannot control -namely, the data dictionary, the SYSTEM rollback segment and deferred rollback segments.

It is actually possible to place much of the data dictionary in another tablespace, and there is sometimes good reason for doing so.However, if you do need to do anything like this, you should get Oracle's blessing first.
The data dictionary segments have very diverse storage requirement, however these are basically static in mature databases.The SYSTEM rollback segment should be lightly used, and thus not require much space management.But deferred rollback segments are the wildcards in SYSTEM tablespace space management.

Deferred rollback segments are also called save undo segments.They are created automatically if a tablespace goes offline with uncommitted changes.Normally, this will only happen in the event of media failure, and only if your database is in archivelog mode.One deferred rollback segment is created for each tablespace affected.Each transaction affected copies the undo records for changes to that tablespace only,from the rollback segment to which it has been writing, into the deferred rollback segment.When the tablespace comes back online again, the undo from transactions that were rolled back is automatically applied,and the deferred rollback segment is dropped.

Deferred rollback segments are created in the SYSTEM tablespace explicitly (not in the SYS schema's default tablespace, if that has been changed).So you need to allow space in the SYSTEM tablespace for deferred rollback segments.There must be at least enough space to accommodate all the outstanding undoagainst any set of tablespaces that may go offline together due to a single media failure.

The most unpleasant thing about the creation of deferred rollback segmentsis that they do not use the SYSTEM tablespace's default INITIAL and NEXT extent sizes, but instead specify tiny 10K extents.However, they do use the SYSTEM tablespace's default PCTINCREASE value.This seems calculated to defeat most attempts to actively manage space in the SYSTEM tablespace.If you change the default PCTINCREASE value for the SYSTEM tablespace to zero, deferred rollback segments will be created in lots of tiny extents.Deferred rollback segments, like the SYSTEM rollback segment, cannot have an unlimited number of extents.The number of extents is limited by the number of slots in the extent control table in the segment header block.To avoid data loss, you must ensure that that limit is never reached for a deferred rollback segment.

This means that you have to choose between the following three options for SYSTEM tablespace space management.

  1. You can (in theory) make SYSTEM a locally managed tablespace using the AUTOALLOCATE policy(the UNIFORM SIZE policy is not available for the SYSTEM tablespace).
  2. You can make SYSTEM a dictionary managed tablespace with a fixed extent size policy.In this case the PCTINCREASE value would be zero, but the extent size would be large enoughto prevent any risk of being unable to extend a deferred rollback segment.
  3. You can make SYSTEM a dictionary managed tablespace with a non-zero PCTINCREASE valueand rely on the MINIMUM EXTENT size feature to limit fragmentation.(This feature is not available prior to Oracle8; but nobody should be creating Oracle7 databases anymore.)

It is not recommended that you make SYSTEM a locally managed tablespace.Extent information for locally managed tablespaces is not cached in the dictionary cache,and in the case of the data dictionary itself this caching is important to the performance of rowcache recursive SQL.(Not to mention that database creation fails if you attempt this anyway unless you've made extensive changes to sql.bsq.)

We also prefer not to use a large fixed extent size for the SYSTEM tablespace.Most of the short-term segments created in the SYSTEM tablespace have very modest space requirements,and using a large fixed extent size is inefficient in terms of space.

We therefore recommend that the data dictionary be created initially with default extent sizes,and that fragmentation be controlled by applying a MINIMUM EXTENT size to the SYSTEM tablespaceimmediately after database creation, as follows:

alter tablespace system minimum extent 64K;
The MINIMUM EXTENT size adopted should be exactly one multiblock read.

Why create databases twice?

But we don't recommend that you leave it there.In fact, we recommend that you create all performance critical databases twice.This first time is just for practice and to take some measurements, so that you can do it perfectly the second time.

Doing it perfectly the second time involves some customization of the sql.bsq file as foreshadowed at the beginning of this tip.Firstly, do not touch the sql.bsq file that comes with your Oracle distribution(in $ORACLE_HOME/rdbms/admin, or in $ORACLE_HOME/dbs).Copy that file to your database creation directory, and edit the copy instead.To use your customized sql.bsq file when recreating the database, you will need to set the _init_sql_file parameter.

The most important thing to change in the sql.bsq file is the SIZE clause of the primary data dictionary clusters,C_OBJ# and C_FILE#_BLOCK#.By default, C_OBJ# is sized for tables with 10 columns and 2 indexes over 2 columns each.Tables with significantly more columns and/or heavier indexing than this will cause cluster block chaining in this cluster unless you prevent it.C_FILE#_BLOCK# is sized for segments with only 5 extents.Segments in dictionary managed tablespaces with significantly more than 5 extentswill cause cluster block chaining in this cluster unless you customize the SIZE clause.

To get the SIZE clauses right, we recommend that you use the APT script dd_cluster_sizes.sql.This script requires that you first create all the database objects that will be required for the application,and extend them to their estimated stable number of extents, if using dictionary managed tablespaces.The script then measures the average space usage per cluster key in the relevant data dictionary clusters,and makes a recommendation for the SIZE clauses.

Since you are going to be editing the sql.bsq file, you also have the opportunity to set appropriate INITIAL and NEXT extent sizesfor all the data dictionary segments that might otherwise immediately require multiple extents.Indeed, you must for the clusters if you have customized their SIZE clauses, otherwise database creation is likely to fail.First, you need to ensure that the data dictionary of your trial database is fully populated,by running all the required catalog scripts, loading all the required optional packages,loading all the stored program units for your application, creating all the users, and analyzing all the segments.You can then use the APT script dd_initial_extents.sqlto get recommended sizes for the INITIAL and NEXT extents for these segments, and edit you copy of sql.bsq accordingly.

On more thing that you can fruitfully do at this point is to run row_migration.sqlto check for row migration problems in the data dictionary, and adopt the suggested PCTFREE settings, if any.The last thing to check before you actually create the database again,is that you have allowed enough free space in the SYSTEM tablespace for the dynamic creation of deferred rollback segments if necessary.


标题基于SpringBoot+Vue的学生交流互助平台研究AI更换标题第1章引言介绍学生交流互助平台的研究背景、意义、现状、方法与创新点。1.1研究背景与意义分析学生交流互助平台在当前教育环境下的需求及其重要性。1.2国内外研究现状综述国内外在学生交流互助平台方面的研究进展与实践应用。1.3研究方法与创新点概述本研究采用的方法论、技术路线及预期的创新成果。第2章相关理论阐述SpringBoot与Vue框架的理论基础及在学生交流互助平台中的应用。2.1SpringBoot框架概述介绍SpringBoot框架的核心思想、特点及优势。2.2Vue框架概述阐述Vue框架的基本原理、组件化开发思想及与前端的交互机制。2.3SpringBoot与Vue的整合应用探讨SpringBoot与Vue在学生交流互助平台中的整合方式及优势。第3章平台需求分析深入分析学生交流互助平台的功能需求、非功能需求及用户体验要求。3.1功能需求分析详细阐述平台的各项功能需求,如用户管理、信息交流、互助学习等。3.2非功能需求分析对平台的性能、安全性、可扩展性等非功能需求进行分析。3.3用户体验要求从用户角度出发,提出平台在易用性、美观性等方面的要求。第4章平台设计与实现具体描述学生交流互助平台的架构设计、功能实现及前后端交互细节。4.1平台架构设计给出平台的整体架构设计,包括前后端分离、微服务架构等思想的应用。4.2功能模块实现详细阐述各个功能模块的实现过程,如用户登录注册、信息发布与查看、在线交流等。4.3前后端交互细节介绍前后端数据交互的方式、接口设计及数据传输过程中的安全问题。第5章平台测试与优化对平台进行全面的测试,发现并解决潜在问题,同时进行优化以提高性能。5.1测试环境与方案介绍测试环境的搭建及所采用的测试方案,包括单元测试、集成测试等。5.2测试结果分析对测试结果进行详细分析,找出问题的根源并
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值