8.01.0200 slow with long queries
am 04.04.2006 11:32:00 von Lasse Haatajapsqlodbc 8.01.0200 is much slower than 8.01.0102 (and earlier versions)
with long (>10 kilobytes) queries; a 1 megabyte query that takes two
seconds with .0102 takes 37 minutes with .0200.
According to mylog, most of the time seems to be taken by PGAPI_NumParams=
..
(Although bind.c seems to be identical in .0102 and .0200, perhaps the
arguments the function is called with makes the difference?)
The culprit seems likely to be the line
for (i =3D 0; i < strlen(stmt->statement); i++)
where strlen is (needlessly, since the string is not modified, let alone
its length changed) evaluated once for each iteration of the loop, result=
ing
in O(N^2) complexity. Fix should be easy, something along the lines of
size_t stmt_len =3D strlen(stmt->statement);
for (i =3D 0; i < stmt_len; i++)
The same problem occurs in misc.c function remove_newlines(); the same fi=
x
appears applicable there as well.
Furthermore, the body of PGAPI_NumParams seems to fail to take into accou=
nt
single quotes escaped by backslashes, instead treating them in the same m=
anner
as literal single quotes, causing queries containing escaped single quote=
s
and question marks in correct sequence (such as SELECT '\'?') to fail. Th=
is
can luckily be worked around (in a standard-compliant manner, no less) by
escaping single quotes with a single quote instead of a backslash, but a =
fix,
at least in the documentation, would be welcome.
--=20
Lasse Haataja, Neagen Oy
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly