nuodb/nuodb-python — pull request #30 by jgetto (2014-02-18 22:42:59+00:00)
Title: Fix pynuodb performance regression

This review has three main changes:

1. Refactor cursor and connection to call encodedsession methods for each complete exchange with the server. Previously these were built up on the fly in in the various cursor and connection methods. This was not directly necessary for the performance fix, but it made statement caching much easier.

2. Properly cache statements. Previously for each execute() a statement would be created, executed, and closed. Now each cursor has one persistent statement for non-prepared queries and a fixed size LRU cache for prepared statements.

3. Set TCP_NODELAY on the session. Small messages (such as CLOSE_STATEMENT which is as most 8 bytes) could take a relatively long time to be sent on linux (It seems that TCP_NODELAY was the default behavior on macosx). With this change alone, a simple "insert in a loop" benchmark runtime was improved dramatically.