Subject Re: [firebird-support] Firebird Prepared Queries
Author Ann W. Harrison
ruan_h wrote:
>
My information may be slightly out of date, in which case
someone will correct me, but here are some answers.
>
> 1. What's the effect of having too many prepared queries in
> each connection? Does Firebird have an optimum number of
> prepared queries kept in cache?

Prepared queries do take up some amount of memory. Probably
not a significant amount of memory on a modern machine. The
space is from the connection's memory, not from the server
page cache.

There is no one optimum number of queries to cache. If
the query will be reused, it should be cached, If it's
generated on the fly, it should not be cached.

> 2. Does Firebird ever unprepare some queries when there
> are too many or does it only do this when clients ask i
> t to? If it's the former, what happens to the handles that
> clients hold to the prepared queries?

Firebird never unprepares a query if a connection holds
a handle to the prepared query.

> 3. If I have an SQL already prepared and I ask for
> prepare the same SQL again, will Firebird return the
> already prepared one or prepare it again?

No, or at least not when I was paying close attention to
it. Firebird does not have a shared query cache between
connections and assumes that a connection will know which
queries it has prepared.


Cheers,

Ann