[Koha-devel] Repetitious behavior repeatedly

paul POULAIN paul.poulain at free.fr
Mon Sep 30 01:56:13 CEST 2002


Andrew Arensburger wrote:

>	Currently, every script and module that requires configuration
>values has a snippet of code that reads /etc/koha.conf. This means
>that a particular operation might cause a script to read
>/etc/koha.conf several times. That can't be good for performance. In
>addition, since the snippet of code is nearly identical everywhere,
>it's just begging to be put into a separate function.
>	To that end, I've written C4::Config module, which reads
>/etc/koha.conf (or a file of your choice, or the file pointed to by
>the $KOHA_CONF environment variable), and caches the results.
>	If people think this is a Good Idea, just let me know where to
>send the code.
>
>	Along those same lines, a lot of functions use
>	$dbh = C4Connect;
>to get a handle to the Koha database. The way C4Connect is
>implemented, it creates a new handle each time. So if 'search.pl'
>finds ten results, it'll open 14 connections to the database. This
>seems wasteful, especially if the web server and database server
>aren't the same machine.
>
I already saw and points this problem a few months ago, but due to lack 
of time...
Note in the new MARC API, EVERY function is called with $dbh being 1st 
parameter... (if one is not : then it's a bug, or it doesn't use db 
access at all)

>	So if C4::Config is well received, I'll also fix C4Connect to
>cache the database handle and return the same one each time, if it
>can.
>	Finally, a number of scripts need to know which branches or
>item types exist. But I'll venture that after the initial setup,
>neither of these changes more than once every few months. It seems
>rather silly to have a script query the database for these values,
>when they could be cached locally.
>	Hence, it would make sense to save this information in a Perl
>module on the web server, so that scripts don't have to query the
>database each time. And run a cron job once an hour to regenerate this
>module from the information in the database.
>	Thoughts? Is this sensible, or am I full of it?
>
I agree. And I can add another table : the "stopword", which is HEAVILY 
used when you add a marc record.
Another idea :
would it be possible to change $dbh to transform it in a "koha param 
object container" having :
* the db handle
* /etc/koha.conf parameters
* some "static" tables
the best would be to be still able to have $dbh->prepare or $dbh->do, 
but to add $dbh->param() to get koha parameter of $dbh->stopwords to get 
hash or array of stopwords...

If we could, then we hadn't to modify all koha API.
--
Paul





More information about the Koha-devel mailing list