Hello,
the clock is sorted now,thanks.
The database i am using is MySQL,and i thought if putting
the "prepare" and "execute" statements in the startup perl
script apache executes while starting. I have also
included in there the Apache::DBI for persistent connections.
I am using placeholders and prepare_cached statements.
Another think I wanted to ask was wether issuing $sth->finish
on cached sql quieries removes them from Mysql cache.

Thanks

-----Original Message-----
From: Stephen Clouse [mailto:[EMAIL PROTECTED]]
Sent: 20 February 2001 11:27 PM
To: Haris
Cc: DBI
Subject: Re: SQL placeholder statements


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Jan 20, 2001 at 11:03:05PM -0000, Haris wrote:
        ^^^
Your system clock is a month off.  Anyway....

> Hello,
> As far as I understood after reading the docs about placeholders in sql
> commands,
> that the benefit gained is only for that specific process.

The assumption here is highly database-dependent.  Some servers (Oracle in
particular, Postgre I believe is adding this if it's not in already)
maintain an
SQL cache and will reuse the cached execution plan if the same SQL is sent
by
any subsequent connection.  Placeholders are highly beneficial in these
cases,
since the statement is the same no matter what you actually bind to the
placeholders at execute time, and thus the cache will be hit.  Consult your
server's documentation to see if it does this sort of caching.

You should be using placeholders either way, if only to spare yourself from
the
pain of proper quoting when interpolating variables into SQL statements, and
in
the case of CGI and other similar programs, to spare yourself from SQL
variable
interpolation attacks.

> I was wondering
> would it be possible to compile all the sql statements at server startup.
> That way all users will get the benefits .I use apache+mod_perl and keep
> persistent
> db connections started from an apache perl script

For those lesser database servers, DBI offers prepare_cached.  Its usage is
well
described in the Fine Manpage.

- --
Stephen Clouse <[EMAIL PROTECTED]>
Senior Programmer, IQ Coordinator Project Lead
The IQ Group, Inc. <http://www.theiqgroup.com/>

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQA/AwUBOpL9TAOGqGs0PadnEQLjDwCgyG44l7jzRDG4zg0EEsFIqF16+PcAn2K4
MUVDNvdwDSJ/vBQIYtPADArE
=l5dR
-----END PGP SIGNATURE-----

Reply via email to