在oracle的proc编程过程中,游标是一个大量使用的特性。但是proc的程序作为oracle的客户端程序,是需要通过通讯与oracle服务端进行交互的。所以在大量数据fetch的过程中,抛开查询本身的问题外,网络交互将成为影响性能的一个重要的指标。
实际上,proc有一个预编译选项,叫做PREFETCH。在oracle的手册中提到:
PREFETCH
Purpose
Use this option to speed up queries by pre-fetching a number of rows.
Syntax
PREFETCH=integer
Default
1
Usage Notes
Can be used in a configuration file or on the command-line. The value of the integer is
used for execution of all queries using explicit cursors, subject to the rules of
precedence.
When used in-line it must placed before OPEN statements with explicit cursors. Then
the number of rows pre-fetched when that OPEN is done is determined by the last
in-line PREFETCH option in effect.
The value range allowed is 0.. 65535.