|
From: | Tony Garnock-Jones |
Subject: | Re: [Chicken-users] status of chickenlib: build process and mysqlinterface usage sample |
Date: | Wed, 01 Sep 2004 20:01:34 +0100 |
User-agent: | Mozilla Thunderbird 0.6 (Macintosh/20040502) |
Ed Watkeys wrote:
Tony Garnock-Jones said:I'm curious - what about the interface makes it too slow?I can only speak in general, but interfaces that return an entire result set consume lots of memory and can introduce lots of latency. For large result sets, the ability to get a row at a time allows for low-latency, constant-space programs.
The main workhorse of Oleg's interface is DB:for-each (which is more of a kind of map, really), which applies a procedure to each row in the result set sequentially. The code uses result-sets internally in the chickenlib implementation; of course, Oleg's reference implementation using pipes and an interactive query tool don't work quite the same :-)
An example use: ... (let ((db (DB:mysql-connect #f mysql-user mysql-pass "mysql"))) (let ((column-names (map string->symbol (DB:fetch-column db "describe host")))) (cout "Columns: " #\newline) (writen column-names) (cout "Values: " #\newline) (DB:for-each (lambda vals (writen (map list column-names vals))) db "select * from host")) (DB:close db)) ...This looks at some of the metadata present in a mysql database, first by grabbing an entire column as a Scheme list using the convenience function DB:fetch-column, and then a row at a time using DB:for-each.
Tony
[Prev in Thread] | Current Thread | [Next in Thread] |