agesys-dev team mailing list archive
-
agesys-dev team
-
Mailing list archive
-
Message #00115
[Bug 1046706] Re: Prepared statements used for all queries
What do you like about prepared statements? Since you can't access them,
they provide you no external benefit as a caller, but give you a
quantifiable performance degradation. The only reason I can think to
like them is it allows the oursql implementation to avoid writing code
to handle string interpolation of SQL arguments. This feels like a
pretty expensive way to avoid client-side string interpolation.
Prepared statements can add some substantial overhead to each individual
transaction, so are really only used when you plan to retain the
statement for frequent use. I'd suggest we default to a dynamic
interface like most other sql libraries, but make available the option
to use prepared statements.
--
You received this bug notification because you are a member of Agesys
Team, which is subscribed to oursql.
https://bugs.launchpad.net/bugs/1046706
Title:
Prepared statements used for all queries
Status in oursql:
New
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.
To manage notifications about this bug go to:
https://bugs.launchpad.net/oursql/+bug/1046706/+subscriptions
References