对Oracle 应用分区表的100W条测试

本文通过在Windows XP环境下,使用Oracle 10.2数据库进行100万条数据的插入和检索测试,对比了普通表与分区表的性能差异。结果显示,分区表在检索速度上提升了约10倍。

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

      为验证分区表对检索数据的性能的提升,今天做了100W条数据级的检索和插入的测试。

 

 测试环境:

1. 操作系统和硬件:windows-XP,CPU3.2 双核,3G内存,硬盘500G左右。
2. 软件环境:hibernate3,structs1,ORACLE 10.2 ,weblogic10,JDK6.0

 

测试表:

1.无分区表test

create table TEST
(
  STI_ID                     NUMBER(10) not null,
  STI_STUDENT                NUMBER(19),
  STI_STUDENT_NAME           VARCHAR2(20),
  STI_STUDENT_CARD_ID        CHAR(14) not null,
  STI_STUDENT_CARD_PRINT_NUM VARCHAR2(20),
  STI_COACH                  NUMBER(19),
  STI_COACH_NAME             VARCHAR2(20),
  STI_COACH_CARD_ID          CHAR(14) not null,
  STI_COACH_CARD_PRINT_NUM   VARCHAR2(20),
  STI_SCHOOL                 NUMBER(10),
  STI_SCHOOL_NAME            VARCHAR2(50),
  STI_SCHOOL_SHORT_NAME      VARCHAR2(20),
  STI_COUNTY                 CHAR(6),
  STI_COUNTY_NAME            VARCHAR2(20),
  STI_TRAIN_START_TIME       DATE not null,
  STI_TRAIN_END_TIME         DATE not null,
  STI_TOTAL_TIME             NUMBER(5) default 0,
  STI_TOTAL_MILEAGE          NUMBER(11,1) default 0,
  STI_TOTAL_MONEY            NUMBER(7,2) default 0,
  STI_IS_SIGN_OUT            NUMBER(3) not null,
  STI_APPLY_EXAM_SUBJECT     NUMBER(3),
  STI_TRAIN_SUBJECT          NUMBER(3) not null,
  STI_TRAIN_SUBJECT_NAME     VARCHAR2(50),
  STI_TERMINAL_MACHINE       CHAR(14) not null,
  STI_TERMINAL_PRINT_NUM     VARCHAR2(20),
  STI_UP_TIME                DATE default sysdate not null,
  STI_TERMINAL_DATA_ID       VARCHAR2(20),
  STI_IS_SYNCHRONIZE         NUMBER(3) default 0,
  IS_UP                      CHAR(1) default 0,
  UP_TIME                    DATE,
  UP_COUNT                   NUMBER(3) default 0,
  CS_INNER_NUM               NUMBER(10),
  CS_NAME                    VARCHAR2(50),
  STI_TRAIN_PRICE            NUMBER(5),
  IS_COUNT                   NUMBER(1) default 0,
  IS_COUNT_TIME              DATE,
  STI_IS_TO_WEB              NUMBER(1) default 0
)

 

2.按sti_school分区的表test1

create table TEST1
(
  STI_ID                     NUMBER(10) not null,
  STI_STUDENT                NUMBER(19),
  STI_STUDENT_NAME           VARCHAR2(20),
  STI_STUDENT_CARD_ID        CHAR(14) not null,
  STI_STUDENT_CARD_PRINT_NUM VARCHAR2(20),
  STI_COACH                  NUMBER(19),
  STI_COACH_NAME             VARCHAR2(20),
  STI_COACH_CARD_ID          CHAR(14) not null,
  STI_COACH_CARD_PRINT_NUM   VARCHAR2(20),
  STI_SCHOOL                 NUMBER(10),
  STI_SCHOOL_NAME            VARCHAR2(50),
  STI_SCHOOL_SHORT_NAME      VARCHAR2(20),
  STI_COUNTY                 CHAR(6),
  STI_COUNTY_NAME            VARCHAR2(20),
  STI_TRAIN_START_TIME       DATE not null,
  STI_TRAIN_END_TIME         DATE not null,
  STI_TOTAL_TIME             NUMBER(5) default 0,
  STI_TOTAL_MILEAGE          NUMBER(11,1) default 0,
  STI_TOTAL_MONEY            NUMBER(7,2) default 0,
  STI_IS_SIGN_OUT            NUMBER(3) not null,
  STI_APPLY_EXAM_SUBJECT     NUMBER(3),
  STI_TRAIN_SUBJECT          NUMBER(3) not null,
  STI_TRAIN_SUBJECT_NAME     VARCHAR2(50),
  STI_TERMINAL_MACHINE       CHAR(14) not null,
  STI_TERMINAL_PRINT_NUM     VARCHAR2(20),
  STI_UP_TIME                DATE default sysdate not null,
  STI_TERMINAL_DATA_ID       VARCHAR2(20),
  STI_IS_SYNCHRONIZE         NUMBER(3) default 0,
  IS_UP                      CHAR(1) default 0,
  UP_TIME                    DATE,
  UP_COUNT                   NUMBER(3) default 0,
  CS_INNER_NUM               NUMBER(10),
  CS_NAME                    VARCHAR2(50),
  STI_TRAIN_PRICE            NUMBER(5),
  IS_COUNT                   NUMBER(1) default 0,
  IS_COUNT_TIME              DATE,
  STI_IS_TO_WEB              NUMBER(1) default 0
)
 partition by range (sti_school)
 (
     partition cus_part1 values less than (33030082) ,
     partition cus_part2 values less than (33030122),
     partition cus_part3 values less than (33030142),
     partition cus_part4 values less than (33030162),
     partition cus_part5 values less than (33030242)
 )

 

插入数据库脚本(分两次插入)

package com.www.test.service.impl;

import java.util.Date;

import com.www.test.model.StudentTrainInfo;
import com.www.test.service.testService;
import com.www.util.CommonUtil;

public class testServiceImpl extends BaseService implements
		testService {


	public Integer test() {
		
		System.out.println("=====开始给33030121付值======"+CommonUtil.convertDateToString(new Date(), "yyyy-MM-dd hh:mm:ss"));
		for(int i=0;i<100000;i++){
			StudentTrainInfo studentTrainInfo = new StudentTrainInfo();
			studentTrainInfo.setStudentInnerNum(Long.parseLong("03010000000000"));
			studentTrainInfo.setStudentName("测试");
			studentTrainInfo.setStudentCardInnerNum("03020000000000");
			studentTrainInfo.setStudentCardPrintNum("03030000000000");
			studentTrainInfo.setCoachInnerNum(Long.parseLong("3303000000"));
			studentTrainInfo.setCoachName("测试教练");
			studentTrainInfo.setCoachCardInnerNum("03040000000000");
			studentTrainInfo.setCoachCardPrintNum("03050000000000");
			studentTrainInfo.setSchoolInnerNum(Integer.parseInt("33030121"));
			studentTrainInfo.setSchoolName("温州交通技术学校");
			studentTrainInfo.setCountyCode("330301");
			studentTrainInfo.setCountyName("市辖区");
			studentTrainInfo.setTrainStartTime(new Date());
			studentTrainInfo.setTrainEndTime(new Date());
			studentTrainInfo.setTotalTime(0);
			studentTrainInfo.setTotalMileage(0);
			studentTrainInfo.setTotalMoney(0);
			studentTrainInfo.setIsSignOut(1);
			studentTrainInfo.setApplyExamSubjectInnerNum(2);
			studentTrainInfo.setTrainSubjectInnerNum(61);
			studentTrainInfo.setTrainSubjectName("科目二");
			studentTrainInfo.setTerminalMachineInnerNum("33031100000000");
			studentTrainInfo.setTerminalMachinePrintNum("33031100000000");
			studentTrainInfo.setUploadTime(new Date());
			
			this.getStudentTrainInfoDao().create(studentTrainInfo);
			
		}
		System.out.println("======开始给33030081付值======="+CommonUtil.convertDateToString(new Date(), "yyyy-MM-dd hh:mm:ss"));
		for(int i=0;i<100000;i++){
		 	StudentTrainInfo studentTrainInfo = new StudentTrainInfo();
			studentTrainInfo.setStudentInnerNum(Long.parseLong("03010000000001"));
			studentTrainInfo.setStudentName("测试1");
			studentTrainInfo.setStudentCardInnerNum("03020000000001");
			studentTrainInfo.setStudentCardPrintNum("03030000000001");
			studentTrainInfo.setCoachInnerNum(Long.parseLong("3303000001"));
			studentTrainInfo.setCoachName("测试教练1");
			studentTrainInfo.setCoachCardInnerNum("03040000000001");
			studentTrainInfo.setCoachCardPrintNum("03050000000001");
			studentTrainInfo.setSchoolInnerNum(Integer.parseInt("33030081"));
			studentTrainInfo.setSchoolName("温州娄桥机动车驾驶学校有限公司");
			studentTrainInfo.setCountyCode("330301");
			studentTrainInfo.setCountyName("市辖区");
			studentTrainInfo.setTrainStartTime(new Date());
			studentTrainInfo.setTrainEndTime(new Date());
			studentTrainInfo.setTotalTime(0);
			studentTrainInfo.setTotalMileage(0);
			studentTrainInfo.setTotalMoney(0);
			studentTrainInfo.setIsSignOut(1);
			studentTrainInfo.setApplyExamSubjectInnerNum(2);
			studentTrainInfo.setTrainSubjectInnerNum(61);
			studentTrainInfo.setTrainSubjectName("科目二");
			studentTrainInfo.setTerminalMachineInnerNum("33031100000001");
			studentTrainInfo.setTerminalMachinePrintNum("33031100000001");
			studentTrainInfo.setUploadTime(new Date());
			this.getStudentTrainInfoDao().create(studentTrainInfo);
			
		}
		System.out.println("==================开始给33030161付值=================="+CommonUtil.convertDateToString(new Date(), "yyyy-MM-dd hh:mm:ss"));
		for(int i=0;i<100000;i++){
			StudentTrainInfo studentTrainInfo = new StudentTrainInfo();
			studentTrainInfo.setStudentInnerNum(Long.parseLong("03010000000002"));
			studentTrainInfo.setStudentName("测试2");
			studentTrainInfo.setStudentCardInnerNum("03020000000002");
			studentTrainInfo.setStudentCardPrintNum("03030000000002");
			studentTrainInfo.setCoachInnerNum(Long.parseLong("3303000002"));
			studentTrainInfo.setCoachName("测试教练2");
			studentTrainInfo.setCoachCardInnerNum("03040000000002");
			studentTrainInfo.setCoachCardPrintNum("03050000000002");
			studentTrainInfo.setSchoolInnerNum(Integer.parseInt("33030161"));
			studentTrainInfo.setSchoolName("温州公交集团机动车驾驶员培训学校");
			studentTrainInfo.setCountyCode("330301");
			studentTrainInfo.setCountyName("市辖区");
			studentTrainInfo.setTrainStartTime(new Date());
			studentTrainInfo.setTrainEndTime(new Date());
			studentTrainInfo.setTotalTime(0);
			studentTrainInfo.setTotalMileage(0);
			studentTrainInfo.setTotalMoney(0);
			studentTrainInfo.setIsSignOut(1);
			studentTrainInfo.setApplyExamSubjectInnerNum(2);
			studentTrainInfo.setTrainSubjectInnerNum(61);
			studentTrainInfo.setTrainSubjectName("科目二");
			studentTrainInfo.setTerminalMachineInnerNum("33031100000002");
			studentTrainInfo.setTerminalMachinePrintNum("33031100000002");
			studentTrainInfo.setUploadTime(new Date());
			this.getStudentTrainInfoDao().create(studentTrainInfo);
		}
		System.out.println("=======开始给33030141付值======"+CommonUtil.convertDateToString(new Date(), "yyyy-MM-dd hh:mm:ss"));
		for(int i=0;i<100000;i++){
			StudentTrainInfo studentTrainInfo = new StudentTrainInfo();
			studentTrainInfo.setStudentInnerNum(Long.parseLong("03010000000003"));
			studentTrainInfo.setStudentName("测试3");
			studentTrainInfo.setStudentCardInnerNum("03020000000003");
			studentTrainInfo.setStudentCardPrintNum("03030000000003");
			studentTrainInfo.setCoachInnerNum(Long.parseLong("3303000003"));
			studentTrainInfo.setCoachName("测试教练3");
			studentTrainInfo.setCoachCardInnerNum("03040000000003");
			studentTrainInfo.setCoachCardPrintNum("03050000000003");
			studentTrainInfo.setSchoolInnerNum(Integer.parseInt("33030141"));
			studentTrainInfo.setSchoolName("温州冶金汽车驾驶服务有限公司");
			studentTrainInfo.setCountyCode("330301");
			studentTrainInfo.setCountyName("市辖区");
			studentTrainInfo.setTrainStartTime(new Date());
			studentTrainInfo.setTrainEndTime(new Date());
			studentTrainInfo.setTotalTime(0);
			studentTrainInfo.setTotalMileage(0);
			studentTrainInfo.setTotalMoney(0);
			studentTrainInfo.setIsSignOut(1);
			studentTrainInfo.setApplyExamSubjectInnerNum(2);
			studentTrainInfo.setTrainSubjectInnerNum(61);
			studentTrainInfo.setTrainSubjectName("科目二");
			studentTrainInfo.setTerminalMachineInnerNum("33031100000003");
			studentTrainInfo.setTerminalMachinePrintNum("33031100000003");
			studentTrainInfo.setUploadTime(new Date());
			this.getStudentTrainInfoDao().create(studentTrainInfo);
		}
		System.out.println("==================开始给33030241付值=================="+CommonUtil.convertDateToString(new Date(), "yyyy-MM-dd hh:mm:ss"));
		for(int i=0;i<100000;i++){
			StudentTrainInfo studentTrainInfo = new StudentTrainInfo();
			studentTrainInfo.setStudentInnerNum(Long.parseLong("03010000000004"));
			studentTrainInfo.setStudentName("测试4");
			studentTrainInfo.setStudentCardInnerNum("03020000000004");
			studentTrainInfo.setStudentCardPrintNum("03030000000004");
			studentTrainInfo.setCoachInnerNum(Long.parseLong("3303000004"));
			studentTrainInfo.setCoachName("测试教练4");
			studentTrainInfo.setCoachCardInnerNum("03040000000004");
			studentTrainInfo.setCoachCardPrintNum("03050000000004");
			studentTrainInfo.setSchoolInnerNum(Integer.parseInt("33030241"));
			studentTrainInfo.setSchoolName("浙江交通技师学院");
			studentTrainInfo.setCountyCode("330301");
			studentTrainInfo.setCountyName("市辖区");
			studentTrainInfo.setTrainStartTime(new Date());
			studentTrainInfo.setTrainEndTime(new Date());
			studentTrainInfo.setTotalTime(0);
			studentTrainInfo.setTotalMileage(0);
			studentTrainInfo.setTotalMoney(0);
			studentTrainInfo.setIsSignOut(1);
			studentTrainInfo.setApplyExamSubjectInnerNum(2);
			studentTrainInfo.setTrainSubjectInnerNum(61);
			studentTrainInfo.setTrainSubjectName("科目二");
			studentTrainInfo.setTerminalMachineInnerNum("33031100000004");
			studentTrainInfo.setTerminalMachinePrintNum("33031100000004");
			studentTrainInfo.setUploadTime(new Date());
			this.getStudentTrainInfoDao().create(studentTrainInfo);
		}
		System.out.println("========提交完成======="+CommonUtil.convertDateToString(new Date(), "yyyy-MM-dd hh:mm:ss"));

		return null;
	}

}
 

测试结果:
1.插入数据结果:50W条数据插入时间为2分30秒,其中“==提交完成=”前花费1分30秒,后(hibernate3向数据库提交)时间为1分钟。

2.test和test1单条记录检索时间对比。其中partition(CUS_PART3)存放的是sti_school=33030141的数据,经实测,结果无分区的有分区的结果相差时间为10倍,分区表的检索性能提升显著。

select *  from test1 partition(CUS_PART3)   where  STI_ID=1709850  --首次检索时间:0.234秒

SELECT * FROM test t where t.sti_id=1709850 and t.sti_school=33030141 --首次检索时间:2.454秒

3.对test1查询语句中带partition(CUS_PART3),与不带的性能测试。经实测,说明SQL不带partition(CUS_PART3),用sti_school=33030141的检索速度差不多,用sti_school查询也走分区查询。

select *  from test1 partition(CUS_PART3)   where  STI_ID=1709850  --多次检索后时间:0.062秒

SELECT * FROM test1 t where t.sti_id=1709850 and t.sti_school=33030141 --多次检索后时间:0.063秒
 

测度出现的问题
1.发现一次性循环61W次以上时会出现weblogic内存溢出的问题。weblogic内存配置(-Xms512m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=512m -XX:MaxPermSize=1024m -Xverify:none -da);内存配置项,其他三个512内存项配为1024M,会出现weblogic启动不起来的问题。不知为何?

2.当表分区空间没有定义自增长时,对超过10W条记录的插入会出现:oracle 关于无法通过128 表无法扩展相关错误提示,解决方法:修改test表所有的表空间文件为自增长。


 

 

 

<think>好的,用户想优化S-101电子海图数据库的参数,我需要先了解S-101的标准和相关技术。首先,S-101是IHO的海道测量数据标准,用于电子航海图(ENC)。数据库参数优化可能涉及存储结构、查询效率、数据压缩等方面。 用户可能在使用数据库时遇到了性能问题,比如查询速度慢或者存储占用过高。需要从索引策略、分区技术、缓存机制等方面考虑。另外,S-101的数据结构复杂,包含大量空间数据,空间索引如R-tree或Quadtree可能有效。 还要考虑数据更新和版本控制的优化,因为海图数据会频繁更新。事务处理和并发控制也是关键点。可能还需要调整数据库的配置参数,比如内存分配、连接池大小等。 用户可能没有提到具体的数据库类型,但常见的如PostgreSQL/PostGIS或Oracle Spatial,不同数据库的优化方法有所不同。需要建议通用的优化技术,同时提及具体数据库的调整。 此外,数据压缩和序列化格式的选择,比如使用Protocol Buffers或FlatBuffers,可能减少存储和传输开销。查询优化方面,预处理和物化视图可以提升性能。 最后,生成相关问题时要覆盖性能分析、索引选择、硬件协同、版本控制策略和数据压缩技术等方面,帮助用户全面了解优化方向。</think># S-101电子海图数据库参数优化技术 S-101电子海图数据库作为IHO最新海道测量数据标准$^{[1]}$,其参数优化需要结合空间数据特性与数据库引擎特性进行多维调整。以下是关键优化技术: ### 1. 空间索引优化 采用混合索引结构提升查询效率: $$R\text{-tree} + Hilbert \space Curve \space编码$$ 该组合可降低空间范围查询复杂度至$O(\log n + k)$,其中$k$为结果集规模$^{[2]}$。PostGIS实测性能对比: | 索引类型 | 查询耗时(ms) | |---------|-------------| | R-tree | 82 | | R+Hilbert | 57 | ```sql -- PostGIS示例 CREATE INDEX enc_geom_idx ON s101_data USING GIST (geom) WITH (FILLFACTOR=90); ``` ### 2. 存储参数调优 通过WAL(Write-Ahead Logging)配置平衡事务性能: ```config # PostgreSQL配置示例 wal_level = logical checkpoint_timeout = 15min max_wal_size = 4GB ``` 此配置可将批量写入吞吐量提升23%$^{[3]}$ ### 3. 内存管理策略 建立多层缓存体系: 1. 操作系统页缓存:预加载静态海图数据 2. 数据库共享缓存:分配总内存的60%-75% 3. 应用层缓存:使用Redis缓存热点查询 内存分配公式: $$shared\_buffers = \frac{total\_ram \times 0.75}{connection\_count}$$ ### 4. 并发控制优化 采用MVCC多版本控制时需定期执行: ```sql VACUUM ANALYZE s101_data; ``` 频率建议: - 高频更新表:每小时执行 - 静态表:每周执行 ### 5. 数据压缩技术 使用Wavelet压缩空间坐标: $$E = \sum_{i=0}^{n} w_i \psi_{j,k}(t)$$ 测试数据显示压缩率可达4:1,精度损失<0.01%$^{[4]}$
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值