prepare_cached() unused in selectall_arrayref() et al

prepare_cached() unused in selectall_arrayref() et al

am 17.12.2005 07:19:30 von dm.list

Why do the higher-level DBI methods such as selectall_arrayref()
internally use prepare() rather than prepare_cached()? or at least why
is there no option to enable that? It seems that the only way to
utilize DBI's internal statement handling caching is to directly call
prepare_cached(), but managing that is not as convenient or transparent
as just using the higher-level methods such as selectall_arrayref().

--davidm

Re: prepare_cached() unused in selectall_arrayref() et al

am 17.12.2005 14:10:43 von mark

On 2005-12-17, David Manura wrote:
> Why do the higher-level DBI methods such as selectall_arrayref()
> internally use prepare() rather than prepare_cached()? or at least why
> is there no option to enable that? It seems that the only way to
> utilize DBI's internal statement handling caching is to directly call
> prepare_cached(), but managing that is not as convenient or transparent
> as just using the higher-level methods such as selectall_arrayref().

I think I had a "use case" to address this:

http://www.mail-archive.com/dbi-users%40perl.org/msg24261.ht ml

In my case "prepare_cached()" didn't scale up well, and I needed to turn
it off. However, I probably had an edge case. Maybe it makes sense to
cache to be default and have an option to turn it off.

Mark

--
http://mark.stosberg.com/

Re: prepare_cached() unused in selectall_arrayref() et al

am 17.12.2005 15:22:03 von Tim.Bunce

On Sat, Dec 17, 2005 at 01:19:30AM -0500, David Manura wrote:
> Why do the higher-level DBI methods such as selectall_arrayref()
> internally use prepare() rather than prepare_cached()? or at least why
> is there no option to enable that?

You can, in a way:

$sth = $dbh->prepare_cached($sql);
$data = $dbh->selectall_arrayref($sth);

or
$data = $dbh->selectall_arrayref( $dbh->prepare_cached($sql) );

> It seems that the only way to
> utilize DBI's internal statement handling caching is to directly call
> prepare_cached(), but managing that is not as convenient or transparent
> as just using the higher-level methods such as selectall_arrayref().

I think the options above strike a reasonable balance. (Especially as
you're the first person to ask about it here for a long time.)

Tim.