
Oraperl version 2 supports a multi-row cache for SELECT statements.
The user interface is not changed, except that the user may (but is
not required to) specify the size of the cache in the &ora_open()
call. It is not possible to go back to an entry which has already been
returned, even if it is still in the cache.

I timed the caching code using the following Oraperl script:

	$lda = &ora_login('ipl', 'name', 'pass') || die $ora_errstr;
	$query = "select * from ipl where modelnum like 'F%001'";

	if ($ora_verno >= 2)
	{
	    $ora_cache = (shift || 0);
	}

	$csr = &ora_open($lda, $query) || die ora_errstr;

	while (@data = &ora_fetch($csr))
	{
	    ++$count;
	}
	warn "($ora_errno) $ora_errstr" if $ora_errno;

	print "Selected $count lines\n";

	&ora_close($csr);
	&ora_logoff($lda);

(I do not claim that this is a good test; it was simply a convenient one!)

The select statement matched 360 rows of 22 fields out a database of 43000
records. The script was run ten times with Oraperl version 1, and ten times
each using cache sizes of 1, 2, 3, 4, 5, 10, 20, 100, 200, 300 and 400. Note
that the size of 400 is greater than the number of rows selected, so they
were all collected in a single fetch. Totaling the figures for each group,
I got the following results:

			 percentage speedup
	cache		   compared to v1
	 size		real	user	sys

	   1		  0	 -2	  1
	   2		  8	  6	 24
	   3		 10	  8	 24
	   4		 12	 12	 27
	   5		 15	 12	 36
	  10		 16	 13	 37
	  20		 18	 13	 39
	 100		 25	 16	 40
	 200		 26	 16	 40
	 300		 26	 16	 40
	 400		 25	 14	 40

Obviously, the larger the cache, the more memory is required. Considering
the relatively small performance improvement obtained by using a large cache
compared with a small one, the default cache size is set to 5 rows.

If you want a different cache size, you can modify the default at compile
time, you can set $ora_cache to the default for your program, or you can
specify the cache size to apply to a particular &ora_open() call by
supplying the number of rows to cache as the third parameter.

For information on caching, see OFEN in the OCI manual.
