Prepared statements used for all queries
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oursql |
New
|
Undecided
|
Unassigned |
Bug Description
I am new to Python and oursql. In diagnosing why queries were so much slower in a Python vs. Ruby application, I noticed you are creating, using and then discarding prepared statements for EVERY query (see cursor.execute). As best as I can tell, this is to avoid dealing with the string interpolation of SQL arguments (e.g. which seems to be handled with varying degrees of success in MySQLdb module). It seems though this is a defect, since the two step process of a prepared statement adds overhead that can be substantial in some use cases. This overhead is typically only of use if you plan on actually re-using the prepared statement.
Assuming my understanding above is correct, I would suggest the current interface should always be dynamic, since you do not intend to cache statements.
I suspect most Python programmers who switched from MySQLdb do not realize the additional overhead they incur for executing a query, since this module defaults to dynamic SQL.
The fact that oursql uses prepared statements is one of the things I like best about oursql.
I would like it if oursql would automatically cache the prepared statements, or would give us some way to cache them ourselves.