WEB开发网
开发学院数据库Oracle 提高Oracle的查询统计速度方法简介 阅读

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

 2007-05-09 12:14:44 来源:WEB开发网   
核心提示: KCB='CREATE TABLE QC_KCB( ' +' CKNM NUMBER(8) ,' +' QCNM NUMBER(10) ,' +' CKKC NUMBER(12,2),' +' SNCKKC NUMBE
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:ORAWIN95DATABASEctl1orcl.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%DATABASEARCHIVE
# define directories to store trace and alert files
background_dump_dest=%RDBMS73%  race
user_dump_dest=%RDBMS73%  race
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数据库设置方法均在用户实际使用中经过了严格测试,证明是有效和实用的。

上一页  1 2 3 

Tags:提高 Oracle 查询

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接