On 2006.03.14, John Ekins <[EMAIL PROTECTED]> wrote:
> After starting aolserver and trying to do a trivial select or insert, 
> for the FIRST time only, there is a lag of about 15 to 20 seconds. 
> Nothing else is using the database. It has one table and two columns, 
> and one row. The config is the same as on Dossy's blog here: 
> http://dossy.org/archives/000104.html.
> 
> After it has selected this entry (or I add another one via aolserver - 
> same delay) all is well and the response is as expected.
> 
> I am not sure what I am doing wrong (if I am doing something wrong) or 
> if anyone else has seen this. The same trivial query runs instantly on 
> MySQL.

Hmm.  It's not unusual that the first query to a database pool will take
longer, because it has to essentially "connect" to the data source -- in
the case of sqlite3, it has to open the database file, read in metadata,
and whatever other housekeeping it must do when opening a database.
Subsequent accesses should definitely be faster.

But, a 15-20 second delay sounds like something is wrong.  How large is
the database file?  Is it on local disk, or an NFS mount, or something
like that?  Is there an error being written into your syslog (disk read
errors, etc.) that could explain the delay on first access to the DB?

What OS/platform are you on?  I'd try tracing the nsd process while you
connect to the DB to see what it's doing when it's doing the 15-20
second wait.

Alternatively, if you can't solve the problem, you could always schedule
something to execute right after server startup to "warm up" the
database, to fire off an empty query to the database.  Like:

    ns_schedule_proc -once 0 {
        set db [ns_db gethandle poolname]
        ns_db exec $db ""
        ns_db releasehandle $db
    }

It's not a solution, but it at least addresses your problem in the short
term.

-- Dossy

-- 
Dossy Shiobara              | [EMAIL PROTECTED] | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to