分享
 
 
 

提高Oracle的查询统计速度方法简介

王朝oracle·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

以Oracle7.33数据库系统为例,我们在开发大型Oracle数据库系统时结合项目的特点,本着安全、高效的原则对数据库进行了一些物理设计,从而大大提高了数据库的查询统计速度。总结为如下几点:

1)扩大数据表空间到500MB,用于存放本系统的数据;

2)段盘区的初始大小为10KB,增长大小为10KB,增长幅度为1;

3)用户临时空间增大40MB;

4)系统临时表空间和回滚段表空间增大40MB,并且新建4个回滚段;

5)需要经常联结查询,而且数据量又大的库存表、名录表、收发料表放在一簇内;

6)提供定时备份,备份文件放在另外的机器上。

设置数据表空间的SQL语句如下:

CREATE TABLESPACE WXGL_DATA1 DATAFILE 'WXGL_DATA1.ORA' SIZE 500M ONLINE;

增加系统临时表空间和回滚段表空间的SQL语句如下:

ALTER TABLESPACE TEMPORARY_DATA ADD DATAFILE 'TMP2ORCL.ORA' SIZE 40M;

ALTER TABLESPACE ROLLBACK_DATA ADD DATAFILE 'RBS2ORCL.ORA' SIZE 40M;

将数据空间设置在指定的数据文件的SQL语句如下:

CREATE USER ZBGL IDENTIFIED BY ZBGL;

GRANT DBA TO ZBGL;

ALTER USER ZBGL DEFAULT TABLESPACE WXGL_DATA1 TEMPORARY TABLESPACE TEMPORARY_DATA;

设置五个回滚段的SQL语句如下:

SELECT SEGMENT_NAME FROM DBA_ROLLBACK_SEGS WHERE INITIAL_EXTENT < 512000 AND

UPPPER(OWNER) = 'PUBLIC';

SELECT UPPER(STATUS) FROM DBA_ROLLBACK_SEGS WHERE UPPER(SEGMENT_NAME) = ''

ALTER ROLLBACK SEGMENT RB1 OFFLINE;

ALTER ROLLBACK SEGMENT RB2 OFFLINE;

ALTER ROLLBACK SEGMENT RB3 OFFLINE;

ALTER ROLLBACK SEGMENT RB4 OFFLINE;

ALTER ROLLBACK SEGMENT RB5 OFFLINE;

DROP ROLLBACK SEGMENT RB1;

DROP ROLLBACK SEGMENT RB2;

DROP ROLLBACK SEGMENT RB3;

DROP ROLLBACK SEGMENT RB4;

DROP ROLLBACK SEGMENT RB5;

CREATE PUBLIC ROLLBACK SEGMENT RB1 TABLESPACE ROLLBACK_DATA

STORAGE (INITIAL 512000 NEXT 512000 MAXEXTENTS 121);

CREATE PUBLIC ROLLBACK SEGMENT RB2 TABLESPACE ROLLBACK_DATA

STORAGE (INITIAL 512000 NEXT 512000 MAXEXTENTS 121);

CREATE PUBLIC ROLLBACK SEGMENT RB3 TABLESPACE ROLLBACK_DATA

STORAGE (INITIAL 512000 NEXT 512000 MAXEXTENTS 121);

CREATE PUBLIC ROLLBACK SEGMENT RB4 TABLESPACE ROLLBACK_DATA

STORAGE (INITIAL 512000 NEXT 512000 MAXEXTENTS 121);

CREATE PUBLIC ROLLBACK SEGMENT RB5 TABLESPACE ROLLBACK_DATA

STORAGE (INITIAL 512000 NEXT 512000 MAXEXTENTS 121);

ALTER ROLLBACK SEGMENT RB1 ONLINE;

ALTER ROLLBACK SEGMENT RB2 ONLINE;

ALTER ROLLBACK SEGMENT RB3 ONLINE;

ALTER ROLLBACK SEGMENT RB4 ONLINE;

ALTER ROLLBACK SEGMENT RB5 ONLINE;

COMMIT;

将数据量大的库存表等放在一簇内的SQL语句如下:

KCB='CREATE TABLE QC_KCB( '

+' CKNM NUMBER(8) ,'

+' QCNM NUMBER(10) ,'

+' CKKC NUMBER(12,2),'

+' SNCKKC NUMBER(12,2),'

+' LDJ NUMBER(12,2),'

+' BZ VARCHAR(100),'

+' PRIMARY KEY(CKNM,QCNM))'

+' TABLESPACE WXGL_DATA1 ' ; (大数据量的库存表等放在WXGL_DATA1)

QCFL = 'CREATE TABLE QC_QCFL '

+ '(FLBH NUMBER(2) PRIMARY KEY,'

+ ' FLMC VARCHAR(20) '

+ ' ) '

+' TABLESPACE WXGL_DATA2 ' ;(其他表放在WXGL_DATA2)

系统的基础数据库存表、名录表大约有数据80M;一个单位一般每年收发300次,收发料单大约有数据50M;系统冗余数据100M,系统辅助数据10M;因此,系统总共需要空间大约是240M,现在系统开辟数据空间500M,完全满足存储要求。由于系统使用了冗余数据,在查询常用数据时,避免了多表联结查询的情况,这样,虽然使用了更多的存储空间,但查询效率大幅度提高;同时,系统将需要经常联结查询的数据放在一簇,即将存放这些数据的空间在物理上相邻,这样也使查询速度大大提高。

另外在oracle7.33数据库的Database目录下有一个Initorcl.ora文件,改变其中的设置也可以提高查询统计速度。该文件的内容如下:

#

# $Header: init.ora 1.2 94/10/18 16:12:36 gdudey Osd $ init.ora Copyr (c) 1991 Oracle

# ##########################################################

# Example INIT.ORA file

#

# This file is provided by Oracle Corporation to help you customize

# your RDBMS installation for your site. Important system parameters

# are discussed, and example settings given.

#

# Some parameter settings are generic to any size installation.

# For parameters that require different values in different size

# installations, three scenarios have been provided: SMALL, MEDIUM

# and LARGE. Any parameter that needs to be tuned according to

# installation size will have three settings, each one commented

# according to installation size.

#

# Use the following table to approximate the SGA size needed for the

# three scenarious provided in this file:

#

# -------Installation/Database Size------

# SMALL MEDIUM LARGE

# Block 2K 4500K 6800K 17000K

# Size4K 5500K 8800K 21000K

#

# To set up a database that multiple instances will be using, place

# all instance-specific parameters in one file, and then have all

# of these files point to a master file using the IFILE command.

# This way, when you change a public

# parameter, it will automatically change on all instances. This is

# necessary, since all instances must run with the same value for many

# parameters. For example, if you choose to use private rollback segments,

# these must be specified in different files, but since all gc_*

# parameters must be the same on all instances, they should be in one file.

#

# INSTRUCTIONS: Edit this file and the other INIT files it calls for

# your site, either by using the values provided here or by providing

# your own. Then place an IFILE= line into each instance-specific

# INIT file that points at this file.#################################################################

db_name = oracle

db_files = 20

control_files = C:\ORAWIN95\DATABASE\ctl1orcl.ora

compatible = 7.3.0.0.0

db_file_multiblock_read_count = 8 # INITIAL

# db_file_multiblock_read_count = 8 # SMALL

# db_file_multiblock_read_count = 16 # MEDIUM

# db_file_multiblock_read_count = 32 # LARGE

db_block_buffers = 200# INITIAL

# db_block_buffers = 200# SMALL

# db_block_buffers = 550 # MEDIUM

# db_block_buffers = 3200 # LARGE

shared_pool_size = 3500000 # INITIAL

# shared_pool_size = 3500000 # SMALL

# shared_pool_size = 6000000 # MEDIUM

# shared_pool_size = 9000000 # LARGE

log_checkpoint_interval = 10000

processes = 50 # INITIAL

# processes = 50 # SMALL

# processes = 100 # MEDIUM

# processes = 200 # LARGE

dml_locks = 100 # INITIAL

# dml_locks = 100 # SMALL

# dml_locks = 200 # MEDIUM

# dml_locks = 500 # LARGE

log_buffer = 8192 # INITIAL

# log_buffer = 8192 # SMALL

# log_buffer = 32768# MEDIUM

# log_buffer = 163840 # LARGE

sequence_cache_entries = 10 # INITIAL

# sequence_cache_entries = 10 # SMALL

# sequence_cache_entries = 30 # MEDIUM

# sequence_cache_entries = 100# LARGE

sequence_cache_hash_buckets = 10 # INITIAL

# sequence_cache_hash_buckets = 10 # SMALL

# sequence_cache_hash_buckets = 23 # MEDIUM

# sequence_cache_hash_buckets = 89 # LARGE

# audit_trail = true # if you want auditing

# timed_statistics = true# if you want timed statistics

max_dump_file_size = 10240 # limit trace file size to 5 Meg each

# log_archive_start = true # if you want automatic archiving

log_archive_dest=%ORACLE_HOME%\DATABASE\ARCHIVE

# define Directories to store trace and alert files

background_dump_dest=%RDBMS73%\trace

user_dump_dest=%RDBMS73%\trace

db_block_size = 2048

snapshot_refresh_processes = 1

remote_login_passWordfile = shared

可以修改该文件的db_file_multiblock_read_count,db_block_buffers,shared_pool_size,processes ,log_buffer,sequence_cache_entries,sequence_cache_hash_buckets等项(文件中均有提示),根据需要和系统使用的数据库服务器的特点适当改大数值,可以提高查询统计速度。这里要注重的是,必须将 log_archive_start = true 项改为False,设置才能生效。

本文介绍的Oracle数据库设置方法均在用户实际使用中经过了严格测试,证实是有效和实用的。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有