之前自己做过一个测试,把这个表的number字段减少一些,速度就快了很多,和平时做的导出就没有任何区别了,可能问题的所在还是在number型字段上。
oracle官方所给的关于buffer的解释如下:
BUFFER
Default: operating system-dependent. See your Oracle operating system-specific documentation to determine the default value for this parameter.
Specifies the size, in bytes, of the buffer used to fetch rows. As a result, this parameter determines the maximum number of rows in an array fetched by Export. Use the following formula to calculate the buffer size:
buffer_size = rows_in_array * maximum_row_size
If you specify zero, then the Export utility fetches only one row at a time.
Tables with columns of type LOBs, LONG, BFILE, REF, ROWID, LOGICAL ROWID, or DATE are fetched one row at a time.
Note:
The BUFFER parameter applies only to conventional path Export. It has no effect on a direct path Export. For direct path Exports, use the RECORDLENGTH parameter to specify the size of the buffer that Export uses for writing to the export file.
Example: Calculating Buffer Size
This section shows an example of how to calculate buffer size.
The following table is created:
CREATE TABLE sample (name varchar(30), weight number);
The maximum size of the name column is 30, plus 2 bytes for the indicator. The maximum size of the weight column is 22 (the size of the internal representation for Oracle numbers), plus 2 bytes for the indicator.
Therefore, the maximum row size is 56 (30+2+22+2).
To perform array operations for 100 rows, a buffer size of 5600 should be specified.
如果说number的字段值有多大,相比varchar2就小很多了。
个人感觉可能是一个bug.
至于为什么buffer设置到9M导出这个表就慢,到底慢在哪儿了?还可以通过strace来做一个很有意义的监控。
我们可以先运行exp的操作,让它先慢慢运行,然后开启strace,假设我们得到的exp的进程号是strace -c -p 25805
就可以通过strace -c -p 25805 来监控这个进程的一些详细信息。运行一会之后就强制中断,得到的结果如下,97%以上的资源都耗在brk操作上了。
> strace -c -p 25805
Process 25805 attached - interrupt to quit
Process 25805 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
97.86 0.001054 6 186 brk
2.14 0.000023 1 30 write
0.00 0.000000 0 12 read
------ ----------- ----------- --------- --------- ----------------
100.00 0.001077 228 total
brk的操作室返回内存管理的起始地址。比如
brk(0x122e3000) = 0x122e3000 就是从0x122e3000 开始分配内存地址。
而如果调小buffer的部分,得到的日志如下:
> strace -c -p 26025
Process 26025 attached - interrupt to quit
Process 26025 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
65.01 0.004096 3 1197 read
34.99 0.002205 1 3522 write
------ ----------- ----------- --------- --------- ----------------
100.00 0.006301 4719 total
可以看到都是读写操作,日志里面也确实导出了不少的数据。
. . exporting partition A11_B10 65222 rows exported
. . exporting partition A12_B1 181825 rows exported
. . exporting partition A12_B2 181783 rows exported
. . exporting partition A12_B3 181582 rows exported
看来这个问题还是和number数据类型存在着一定的关系,大家在数据导出的时候如果碰到这个问题也可以注意一下。