| Issue 17: | Regain performance lost since 2.0.36 |
1 of 179
Next ›
|
| 1 person starred this issue and may be notified of changes. | Back to list |
As reported by Joe Salmeri (via email), the 2.1.x is slower than the 2.0.x branch. After examining some ODBC trace logs, we determined that it was extra SQLDescribeParam calls that were added to work around binding None/NULL. When passing parameters, pyodbc has to tell the driver the data type of the parameter. When None is passed, pyodbc obviously doesn't know -- it is NULL and there is no way to tell if it is going into a character column, an integer, etc. In the 2.0 branch, pyodbc always set the data type to char, but SQL Server will not let you insert a character value into a binary column even if you are passing NULL. To fix this, I use SQLDescribeParam, if supported by the driver, to determine the correct data type. Unfortunately, this adds 1 driver call per parameter for every query, which is way too much overhead.
Dec 29, 2008
Project Member
#1
mkleehammer
Nov 28, 2010
Are you actively working on this? I'm looking for a project to learn python on c-level and I've been playing with pyodbc a couple of days. I was thinking: - create a hashtable with hashes for each statement, both for fast lookup and to prevent sql-code hanging around in-memory - instead of caching N statements, to cache all statements, add a 'lastused' ticker and flush statements that were not re-used for x seconds, optionally settable by user (where x=0 means no cache) I'd not be fast, thinking in term of months go get this right.
Feb 6, 2011
How about adding a way to specify the types manually, for example, by exposing them as classes? Something like this: cursor.execute('select Helloworld = ?', pyodbc.types.Binary(None))
Feb 6, 2011
Another benefit of specifying types manually is that pyodbc could then work better with ODBC drivers which do not implement SQLDescribeParam, eg FreeTDS.
Feb 13, 2011
Yes, and in addition to that, there are databases which do not implement SQLDescribeParam as well, for example, Sybase. |