X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 6022B11F6553 for ; Tue, 4 Apr 2006 08:14:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33695-03 for ; Tue, 4 Apr 2006 08:14:34 -0300 (ADT) X-Greylist: delayed 00:53:33.202619 by SQLgrey- Received: from fep32-app.kolumbus.fi (fep32-0.kolumbus.fi [193.229.0.63]) by postgresql.org (Postfix) with ESMTP id 4C4C711F61F8 for ; Tue, 4 Apr 2006 08:14:31 -0300 (ADT) Received: from gabrielle.neagen-int.com ([82.128.220.225]) by fep10-app.kolumbus.fi with ESMTP id <20060404093203.DDI14806.fep10-app.kolumbus.fi@gabrielle.neagen-int.com> for ; Tue, 4 Apr 2006 12:32:03 +0300 Date: Tue, 04 Apr 2006 12:32:00 +0300 To: pgsql-odbc@postgresql.org Subject: 8.01.0200 slow with long queries From: "Lasse Haataja" Organization: Neagen Oy Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: User-Agent: Opera M2/7.54 (Win32, build 3865) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200604/19 X-Sequence-Number: 7546 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