实例演示使用并行和非并行选项的性能差异
比较direct方式使用并行和非并行选项的性能差异。 并行测试 创建测试表 create table sqlldr_paral nologging PARTITION BY HASH (sfzh) (partition p1 tablespace users , partition p2tablespace zdry_tbs2 ) AS SELECT *FROM sfxx2 where 1=2 ; sqlldr_pa
比较direct方式使用并行和非并行选项的性能差异。
并行测试
创建测试表
create table sqlldr_paral
nologging
PARTITION BY HASH (sfzh)
(partition p1 tablespace users , partition p2tablespace zdry_tbs2 )
AS SELECT *FROM sfxx2 where 1=2 ;
sqlldr_paral.ctl
LOAD DATA
INFILE 'd:\flatfile\flatfile.dat'
APPEND
INTO TABLE sqlldr_paral
fields terminated by X'23'
TRAILING NULLCOLS
(zj,
…字段太多省略
cjdwdm)
sqlldr_paral.par
USERID=zdrygk/zdrygk
CONTROL='d:\flatfile\sqlldr_paral.ctl'
DATA='d:\flatfile\flatfile.dat'
LOG='d:\flatfile\sqlldr_paral.log'
DIRECT=true
parallel=true
ERRORS=10000
执行
D:\flatfile>sqlldrparfile=d:\flatfile\sqlldr_paral.par
SQL*Loader: Release 11.2.0.1.0 - Production onMon Jan 7 23:21:42 2013
Copyright (c) 1982, 2009, Oracle and/or itsaffiliates. All rights reserved.
Load completed - logical record count 3022375.
sqlldr_paral.log
Control File: d:\flatfile\sqlldr_paral.ctl
Data File: d:\flatfile\flatfile.dat
BadFile: d:\flatfile\flatfile.bad
DiscardFile: none specified
(Allowall discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 10000
Continuation: none specified
Path used: Direct- with parallel option. -----这里指定了并行选项
Table SQLLDR_PARAL, loaded from every logicalrecord.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Table SQLLDR_PARAL:
3017264Rows successfully loaded.
5111Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauseswere failed.
0 Rowsnot loaded because all fields were null.
Dateconversion cache disabled due to overflow (default size: 1000)
Partition P1: 1509091 Rows loaded.
Partition P2: 1508173 Rows loaded.
Bind array size not used in direct path.
Column array rows : 5000
Stream buffer bytes: 256000
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 3022375
Total logical records rejected: 5111
Total logical records discarded: 0
Total stream buffers loaded by SQL*Loader mainthread: 1301
Total stream buffers loaded by SQL*Loader loadthread: 3901
Run began on Mon Jan 07 23:21:42 2013
Run ended on Mon Jan 07 23:22:18 2013
Elapsed time was: 00:00:35.91
CPU time was: 00:00:25.79
非并行测试
创建测试表
create table sqlldr_nopal
nologging
PARTITION BY HASH (sfzh)
(partition p1 tablespace users , partition p2tablespace zdry_tbs2 )
AS SELECT *FROM sfxx2 where 1=2 ;
sqlldr_nopar.ctl
LOAD DATA
INFILE 'd:\flatfile\flatfile.dat'
APPEND
INTO TABLEsqlldr_nopar
fields terminated by X'23'
TRAILING NULLCOLS
(zj,
…字段太多省略
cjdwdm)
sqlldr_nopar.par
这里删除了并行选项
USERID=zdrygk/zdrygk
CONTROL='d:\flatfile\sqlldr_nopar.ctl'
DATA='d:\flatfile\flatfile.dat'
LOG='d:\flatfile\sqlldr_nopar.log'
DIRECT=true
ERRORS=10000
执行
D:\flatfile>sqlldrparfile=d:\flatfile\sqlldr_nopar.par
SQL*Loader: Release 11.2.0.1.0 - Production onMon Jan 7 23:20:54 2013
Copyright (c) 1982, 2009, Oracle and/or itsaffiliates. All rights reserved.
Load completed - logical record count 3022375.
sqlldr_nopar.log
Control File: d:\flatfile\sqlldr_nopar.ctl
Data File: d:\flatfile\flatfile.dat
BadFile: d:\flatfile\flatfile.bad
DiscardFile: none specified
(Allowall discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 10000
Continuation: none specified
Path used: Direct ----这里只是指定了直接路径加载
Table SQLLDR_NOPAR, loaded from every logicalrecord.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Table SQLLDR_NOPAR:
3017264Rows successfully loaded.
5111Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauseswere failed.
0 Rowsnot loaded because all fields were null.
Dateconversion cache disabled due to overflow (default size: 1000)
Partition P1: 1509091 Rows loaded.
Partition P2: 1508173 Rows loaded.
Bind array size not used in direct path.
Column array rows : 5000
Stream buffer bytes: 256000
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 3022375
Total logical records rejected: 5111
Total logical records discarded: 0
Total stream buffers loaded by SQL*Loader mainthread: 1301
Total stream buffers loaded by SQL*Loader loadthread: 3901
Run began on Mon Jan 07 23:20:54 2013
Run ended on Mon Jan 07 23:21:28 2013
Elapsed time was: 00:00:33.81
CPU time was: 00:00:25.32
分析
Load Mode |
Elapsed time(ss.99) |
Direct |
33.81 |
Direct + parallel |
35.91 |
笔者做了多次试验,除了第一次消耗时间较长(因为表空间自动拓展),后面的实验中两种模式的用时大致相同。自己猜测在使用Direct 直接路径加载的情况下,多线程并不能提高效率。
在Util中找到关于sql*loader command line的描述
PARALLEL(parallel load)
Default: false
PARALLELspecifies whether direct loads canoperate in multiple concurrent sessions
to load data into the same table.
parallel这个参数用来设定使用direct loads的时候是否使用并发的session去加载数据到相同的表中。
于是测试了多文件,多session加载数据的情况。
D:\flatfile>sqluldr2 user=zdrygk/zdrygk@orclquery=sfxx2 degree=8 file=d:\flatfile\ldrfiles%t.dat field=0x23 size=300MB
0rows exported at 2013-01-08 00:07:26, size 0 MB.
output file d:\flatfile\ldrfiles1357574846.dat closed at 707972 rows,size 304 MB.
output file d:\flatfile\ldrfiles1357574861.dat closed at 697498 rows,size 604 MB.
output file d:\flatfile\ldrfiles1357574876.dat closed at 701379 rows,size 904 MB.
output file d:\flatfile\ldrfiles1357574891.dat closed at 692556 rows,size 1204 MB.
222868rows exported at 2013-01-08 00:08:31, size 1300 MB.
output file d:\flatfile\ldrfiles1357574906.dat closed at 222868 rows,size 1300 MB.
一共5个文件。
多文件并行测试
如果指定了parallel选项,sqlldr运行的时候会对表加4级锁,允许多个sqlldr session同时对同一个表执行加载作用。在我们执行了truncate 操作后对表进行并行加载操作。
parallelpar1文件
USERID=zdrygk/zdrygk
CONTROL='D:\flatfile\multifile\paral\sqlldr_paral_1.ctl'
DATA='D:\flatfile\multifile\ldrfiles1357574846.dat'
LOG='D:\flatfile\multifile\paral\sqlldr_paral_1.log'
DIRECT=true
parallel=true
ERRORS=10000
parallel par2、3、4、5的内容大致相同。
在windows下只能打开多个窗口,通过复制粘贴的方法保证并行了。
执行
sqlldrparfile=D:\flatfile\multifile\paral\sqlldr_paral_1.par
sqlldrparfile=D:\flatfile\multifile\paral\sqlldr_paral_2.par
sqlldrparfile=D:\flatfile\multifile\paral\sqlldr_paral_3.par
sqlldr parfile=D:\flatfile\multifile\paral\sqlldr_paral_4.par
sqlldrparfile=D:\flatfile\multifile\paral\sqlldr_paral_5.par
最后得到了5个log文件关键内容:
log1
Run began on Tue Jan 08 01:51:11 2013
Run ended on Tue Jan 08 01:51:21 2013
Elapsed time was: 00:00:09.42
CPU time was: 00:00:06.43
…
中间的几个log文件省略
log5
Run began on Tue Jan 08 01:51:34 2013
Run ended on Tue Jan 08 01:51:38 2013
Elapsed time was: 00:00:03.27
CPU time was: 00:00:02.03
因为最后一个sqlldr session 是最后一个执行结束的,所以需要计算并行sqlldr的执行消耗时间,只需要使用log5中的结束时间减去log1中的开始时间即可。
01:51:38-01:51:11=22秒
因为不是使用程序执行这几个sqlldr程序,复制、粘贴、执行之间会有空隙。真实用时应该比22秒这个数字要小的多。
多文件非并行测试
因为如果没有指定parallel选项,sqlldr运行的时候会对表加6级锁,其他sqlldr session会无法工作,所以只能串行的执行sqlldr操作。在我们执行了truncate操作之后对表进行串行加载操作。
noparallelpar1文件
USERID=zdrygk/zdrygk
CONTROL='D:\flatfile\multifile\nopar\sqlldr_nopar_1.ctl'
DATA='D:\flatfile\multifile\ldrfiles1357574846.dat'
LOG='D:\flatfile\multifile\nopar\sqlldr_nopar_1.log'
DIRECT=true
ERRORS=10000
noparallel par2、3、4、5的内容大致相同。
执行
sqlldrparfile=D:\flatfile\multifile\nopar\sqlldr_nopar_1.par
sqlldr parfile=D:\flatfile\multifile\nopar\sqlldr_nopar_2.par
sqlldrparfile=D:\flatfile\multifile\nopar\sqlldr_nopar_3.par
sqlldrparfile=D:\flatfile\multifile\nopar\sqlldr_nopar_4.par
sqlldrparfile=D:\flatfile\multifile\nopar\sqlldr_nopar_5.par
最后得到了5个log文件关键内容:
log1
Run began on Tue Jan 08 01:47:35 2013
Run ended on Tue Jan 08 01:47:48 2013
Elapsed time was: 00:00:12.61
CPU time was: 00:00:06.92
…
中间的几个log文件省略
log5
Run began on Tue Jan 08 01:48:26 2013
Run ended on Tue Jan 08 01:48:30 2013
Elapsed time was: 00:00:03.68
CPU time was: 00:00:02.01
最后执行时间相加
12.61+ 12.54+ 12.09+ 11.40+ 03.68=52.32秒
总结
Load Mode |
Elapsed time(ss.99) |
Direct |
52.32 |
Direct + parallel |
22 |
sqlldr是cpu密集型的操作,并且多线程,只有在使用多个数据文件,并且开启多个sqlldr session的时候才会有效果。并且效果非常明显。在消耗更多cpu和内存的同时能够给予非常高的效率,在真实情况下与单文件加载相比效率相差有1倍以上。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

MetaMask(中文也叫小狐狸钱包)是一款免费的、广受好评的加密钱包软件。目前,BTCC已支持绑定MetaMask钱包,绑定后可使用MetaMask钱包进行快速登入,储值、买币等,且首次绑定还可获得20USDT体验金。在BTCCMetaMask钱包教学中,我们将详细介绍如何注册和使用MetaMask,以及如何在BTCC绑定并使用小狐狸钱包。MetaMask钱包是什么?MetaMask小狐狸钱包拥有超过3,000万用户,是当今最受欢迎的加密货币钱包之一。它可免费使用,可作为扩充功能安装在网络

Ollama是一款超级实用的工具,让你能够在本地轻松运行Llama2、Mistral、Gemma等开源模型。本文我将介绍如何使用Ollama实现对文本的向量化处理。如果你本地还没有安装Ollama,可以阅读这篇文章。本文我们将使用nomic-embed-text[2]模型。它是一种文本编码器,在短的上下文和长的上下文任务上,性能超越了OpenAItext-embedding-ada-002和text-embedding-3-small。启动nomic-embed-text服务当你已经成功安装好o

小米汽车软件提供远程车控功能,让用户可以通过手机或电脑远程控制车辆,例如开关车辆的门窗、启动引擎、控制车辆的空调和音响等,下文就是这个软件的使用及内容,一起了解下吧。小米汽车app功能及使用方法大全1、小米汽车app在3月25日上线苹果AppStore,现在安卓手机的应用商店中也可以下载了;购车:了解小米汽车核心亮点和技术参数,可预约试驾、配置订购您的小米汽车,支持在线处理提车待办事项。3、社区:了解小米汽车品牌资讯,交流用车体验,分享精彩车生活;4、车控:手机就是遥控器,远程控制,实时安防,轻

PHP数组键值翻转方法性能对比表明:array_flip()函数在大型数组(超过100万个元素)下比for循环性能更优,耗时更短。手动翻转键值的for循环方法耗时相对较长。

不同Java框架的性能对比:RESTAPI请求处理:Vert.x最佳,请求速率达SpringBoot2倍,Dropwizard3倍。数据库查询:SpringBoot的HibernateORM优于Vert.x及Dropwizard的ORM。缓存操作:Vert.x的Hazelcast客户机优于SpringBoot及Dropwizard的缓存机制。合适框架:根据应用需求选择,Vert.x适用于高性能Web服务,SpringBoot适用于数据密集型应用,Dropwizard适用于微服务架构。

函数对C++程序性能的影响包括函数调用开销、局部变量和对象分配开销:函数调用开销:包括堆栈帧分配、参数传递和控制权转移,对小函数影响显着。局部变量和对象分配开销:大量局部变量或对象创建和销毁会导致堆栈溢出和性能下降。

Go语言是一种简单、高效、并发性强的编程语言,它是由Google开发的一种开源语言。在Go语言中,空格的使用是非常重要的,它能够提高代码的可读性和易维护性。本文将介绍如何正确地在Go语言中使用空格,并提供具体的代码示例。为什么需要正确使用空格在编程过程中,空格的使用对于代码的可读性和美观性非常重要。恰当地使用空格可以让代码更加清晰、易读,从而减

优化C++多线程性能的有效技术包括:限制线程数量,避免争用资源。使用轻量级互斥锁,减少争用。优化锁的范围,最小化等待时间。采用无锁数据结构,提高并发性。避免忙等,通过事件通知线程资源可用性。
