RE: Memoizing non-place-holding sql statements to place-holding
- From: h-taguchi@xxxxxxxxxxx
- Date: Mon, 29 Aug 2005 14:23:05 +0900
Thanks, maybe I understand it.
By using prepare_cached method, I can do without a
hash like %cached_statments, and I can get a benefit from
all modules I'm making.
Regards,
Hirosi Taguti
h-taguchi@xxxxxxxxxxx
> -----Original Message-----
> From: Steven Lembark [mailto:lembark@xxxxxxxxxxx]
> Sent: Monday, August 29, 2005 2:08 AM
> To: Hirosi Taguti; dbi-users@xxxxxxxx
> Subject: RE: Memoizing non-place-holding sql statements to
> place-holding
>
>
> > I've read DBI doc but I cann't understand prepare_cached.
> > Any difference between prepare and prepare_cached?
>
> prepare_cached is useful if you are going to re-use
> a statement handle. It stores the statement handle
> in a hash keyed by the sql statement itself. This
> saves re-preparing the statement if it is reused:
>
> For example:
>
> my $sth = $dbh->prepare_cached( 'select foo from bar' );
>
> Calls code like:
>
> my $dbh = shfit;
> my $sql = shift;
>
> ...
>
> $cached_statments{ $sql } ||= $dbh->prepare( $sql );
>
> This only does the prepare once (when the ||= finds a
> false value in %prepared_statements).
>
> These are useful when you are going to re-run the same
> query any number of times from different parts of the
> code.
>
>
>
> --
> Steven Lembark 85-09 90th Street
> Workhorse Computing Woodhaven, NY 11421
> lembark@xxxxxxxxxxx 1 888 359 3508
>
.
- Prev by Date: RE: Memoizing non-place-holding sql statements to place-holding
- Next by Date: ANNOUNCE: DBD::monetdb 0.06
- Previous by thread: RE: Memoizing non-place-holding sql statements to place-holding
- Next by thread: DBD Oracle column type
- Index(es):
Relevant Pages
|
|