足球游戏_中国足彩网¥体育资讯$

提高Oracle的查询统计速度方法简介
来源:易贤网 阅读:1556 次 日期:2015-04-27 14:53:16
温馨提示:易贤网小编为您整理了“提高Oracle的查询统计速度方法简介”,方便广大网友查阅!

以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 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

# Size 4K 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数据库设置方法均在用户实际使用中经过了严格测试,证明是有效和实用的。

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看数据库
易贤网手机网站地址:提高Oracle的查询统计速度方法简介
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!

2025国考·省考课程试听报名

  • 报班类型
  • 姓名
  • 手机号
  • 验证码
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65099533/13759567129 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标