pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feed8.01.0200 slow with long queries
3+ messages / 2 participants
[nested] [flat]
* 8.01.0200 slow with long queries
@ 2006-04-04 09:32 Lasse Haataja <lasse.haataja@neagen.com>
0 siblings, 0 replies; 3+ messages in thread
From: Lasse Haataja @ 2006-04-04 09:32 UTC (permalink / raw)
To: pgsql-odbc
psqlodbc 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 = 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, resulting
in O(N^2) complexity. Fix should be easy, something along the lines of
size_t stmt_len = strlen(stmt->statement);
for (i = 0; i < stmt_len; i++)
The same problem occurs in misc.c function remove_newlines(); the same fix
appears applicable there as well.
Furthermore, the body of PGAPI_NumParams seems to fail to take into account
single quotes escaped by backslashes, instead treating them in the same manner
as literal single quotes, causing queries containing escaped single quotes
and question marks in correct sequence (such as SELECT '\'?') to fail. This
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.
--
Lasse Haataja, Neagen Oy
^ permalink raw reply [nested|flat] 3+ messages in thread
* [ psqlodbc-Bugs-1000604 ] 8.01.0200 slow with long queries
@ 2006-04-04 10:45 noreply@pgfoundry.org
0 siblings, 0 replies; 3+ messages in thread
From: noreply@pgfoundry.org @ 2006-04-04 10:45 UTC (permalink / raw)
To: noreply@pgfoundry.org
Bugs item #1000604, was opened at 2006-04-04 13:45
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1000604&group_id=1000125
Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Lasse Haataja (lhaataja)
Assigned to: Nobody (None)
Summary: 8.01.0200 slow with long queries
Initial Comment:
psqlodbc 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 = 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, resulting
in O(N^2) complexity. Fix should be easy, something along the lines of
size_t stmt_len = strlen(stmt->statement);
for (i = 0; i < stmt_len; i++)
The same problem occurs in misc.c function remove_newlines(); the same fix
appears applicable there as well.
----------------------------------------------------------------------
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1000604&group_id=1000125
^ permalink raw reply [nested|flat] 3+ messages in thread
* [ psqlodbc-Bugs-1000604 ] 8.01.0200 slow with long queries
@ 2006-04-28 08:22 noreply@pgfoundry.org
0 siblings, 0 replies; 3+ messages in thread
From: noreply@pgfoundry.org @ 2006-04-28 08:22 UTC (permalink / raw)
To: noreply@pgfoundry.org
Bugs item #1000604, was opened at 2006-04-04 10:45
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1000604&group_id=1000125
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 3
Submitted By: Lasse Haataja (lhaataja)
Assigned to: Nobody (None)
Summary: 8.01.0200 slow with long queries
Initial Comment:
psqlodbc 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 = 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, resulting
in O(N^2) complexity. Fix should be easy, something along the lines of
size_t stmt_len = strlen(stmt->statement);
for (i = 0; i < stmt_len; i++)
The same problem occurs in misc.c function remove_newlines(); the same fix
appears applicable there as well.
----------------------------------------------------------------------
Comment By: Lasse Haataja (lhaataja)
Date: 2006-04-05 07:28
Message:
This is fixed in 07.03.0260 (The strlen evaluated every
iteration is still present in the source in
remove_newlines(), but the function doesn't seem to be used
at all, so no problem there).
----------------------------------------------------------------------
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1000604&group_id=1000125
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-04-28 08:22 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-04 09:32 8.01.0200 slow with long queries Lasse Haataja <lasse.haataja@neagen.com>
2006-04-04 10:45 [ psqlodbc-Bugs-1000604 ] 8.01.0200 slow with long queries noreply@pgfoundry.org
2006-04-28 08:22 [ psqlodbc-Bugs-1000604 ] 8.01.0200 slow with long queries noreply@pgfoundry.org
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox