+1 ----- Original Message ---- From: Dossy Shiobara <[EMAIL PROTECTED]> To: AOLSERVER@LISTSERV.AOL.COM Sent: Wednesday, April 16, 2008 7:00:14 PM Subject: Re: [AOLSERVER] ns_db and bind variable support
On 2008.04.17, Bas Scheffers <[EMAIL PROTECTED]> wrote: > That brings me to another subject: do we want prepared statements? Yes! In web applications, one of the big performance hits is SQL query parse time. The irony is, in web applications, the queries aren't really dynamic: most can be parsed once, and different bind variable values used at execution time. In my local sandbox, where I've been hacking on bind variable support, I also implemented an [ns_db prepare] which returns an opaque ID to an entry in a prepared statement cache. The concept looks like this: set stmt [ns_db prepare ?-pool $pool | -handle $handle? $sql] set values [list a 1 b 2 ... z 26] ns_db exec -statement $stmt $values Or, something very much like that. One thought, to avoid having application code store and save and retrieve the statement handle between requests was to hash the SQL statement and make the opaque ID the hash. The unlikely hash collision issue aside, this could fail where a prepared statement can't be cached (and there's no way for nsdb to "know" this)--so, caching/reuse of prepared statements really should be left up to the application code, as the developer ought to know when it can be reused vs. when it should be flushed/re-prepared. -- 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. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- 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.