Subject | Web Apps - cache lost when db disconnects |
---|---|
Author | jeff_j_dunlap |
Post date | 2008-10-16T00:27:08Z |
I am using Firebird 2.0.3 running on a Windows 2003 Web Ed. It has
worked very reliably but I've had to experiment with workarounds in
order to keep my database cached after disconnecting from it.
The performance hit (due to lost db cache) is easily overcome simply
by LEAVING THE DATABASE OPEN but I've been told that keeping it open
indefinately is not a good idea for FB. I've noticed that even if a
secondary application has the database open, the cache is not lost.
Users on the IBPP newsgroup mentioned that they have not observed this
loss of buffering, but they run Firebird on non Windows OSs. On
Windows, it is definately lost the moment you disconnect from the
database.
Here is my working SQL code (using the IBPP library):
db = IBPP::DatabaseFactory("127.0.0.1", DbName, UserName, Password);
db->Connect();
tr = IBPP::TransactionFactory(db);
tr->Start();
st = IBPP::StatementFactory(db, tr);
st->Prepare(sSQL);
st->Execute();
tr->Commit();
db->Disconnect(); // buffering wiped out
Users of the IBPP newsgroup suggested creating a database connection
pool for my web app but this seems like an extra headache.
My 'hodgepodge' workaround has been to keep a single 'dummy' instance
of the database open for several hours doing nothing. This keeps the
database buffered. I close and reopen this 'dummy' instance every 4
hours so that FB can do it's housekeeping (or whatever it has to do).
Doing this allows the database to stay buffered while other instances
(using the connect/disconnect code above) do the actual db work.
Is there anything in newer versions of FB (or in the works) to allow
FB to buffer the database for a period of time after applications
disconnect from them?
Thank you very much,
Jeff
worked very reliably but I've had to experiment with workarounds in
order to keep my database cached after disconnecting from it.
The performance hit (due to lost db cache) is easily overcome simply
by LEAVING THE DATABASE OPEN but I've been told that keeping it open
indefinately is not a good idea for FB. I've noticed that even if a
secondary application has the database open, the cache is not lost.
Users on the IBPP newsgroup mentioned that they have not observed this
loss of buffering, but they run Firebird on non Windows OSs. On
Windows, it is definately lost the moment you disconnect from the
database.
Here is my working SQL code (using the IBPP library):
db = IBPP::DatabaseFactory("127.0.0.1", DbName, UserName, Password);
db->Connect();
tr = IBPP::TransactionFactory(db);
tr->Start();
st = IBPP::StatementFactory(db, tr);
st->Prepare(sSQL);
st->Execute();
tr->Commit();
db->Disconnect(); // buffering wiped out
Users of the IBPP newsgroup suggested creating a database connection
pool for my web app but this seems like an extra headache.
My 'hodgepodge' workaround has been to keep a single 'dummy' instance
of the database open for several hours doing nothing. This keeps the
database buffered. I close and reopen this 'dummy' instance every 4
hours so that FB can do it's housekeeping (or whatever it has to do).
Doing this allows the database to stay buffered while other instances
(using the connect/disconnect code above) do the actual db work.
Is there anything in newer versions of FB (or in the works) to allow
FB to buffer the database for a period of time after applications
disconnect from them?
Thank you very much,
Jeff