X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 76677DA541 for ; Fri, 21 Oct 2005 12:57:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35534-09 for ; Fri, 21 Oct 2005 15:57:17 +0000 (GMT) Received: from newmail.brightech.com (216-243-189-65.colonial.bitstream.net [216.243.189.65]) by svr1.postgresql.org (Postfix) with SMTP id 8509ED6EDE for ; Fri, 21 Oct 2005 12:57:14 -0300 (ADT) Received: (qmail 23012 invoked from network); 21 Oct 2005 15:57:14 -0000 Received: from unknown (HELO ?192.168.1.201?) (192.168.1.201) by newmail.brightech.com with SMTP; 21 Oct 2005 15:57:14 -0000 Mime-Version: 1.0 (Apple Message framework v734) To: pgsql-jdbc@postgresql.org Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-1--868310100 From: Sergei Rogovskiy Subject: Speed up fixes Date: Fri, 21 Oct 2005 10:57:08 -0500 X-Mailer: Apple Mail (2.734) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/109 X-Sequence-Number: 14040 --Apple-Mail-1--868310100 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hello, Unfortunately JDBC drivers for PostgreSQL are always in hot spots on heavy database usage. I've looked through and fixed 2-3 obvious performance leaks which saves 20-30% CPU usage percents for our application. If you are interested please review and commit to your source tree. See attached diff file for version 8.0.316. Thanks, -- Sergei Rogovskiy Brightech Inc. --Apple-Mail-1--868310100 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="speedup.patch" Content-Disposition: attachment; filename=speedup.patch *** ./org/postgresql/core/v3/QueryExecutorImpl.java Fri Oct 14 12:34:44 2005 --- ../postgresql-jdbc-8.0-313.src original/./org/postgresql/core/v3/QueryExecutorImpl.java Tue Feb 1 01:27:54 2005 *************** *** 59,65 **** // also break the query into separate statements. ArrayList statementList = new ArrayList(); ! ArrayList fragmentList = new ArrayList(15); boolean inQuotes = false; int fragmentStart = 0; --- 59,65 ---- // also break the query into separate statements. ArrayList statementList = new ArrayList(); ! ArrayList fragmentList = new ArrayList(); boolean inQuotes = false; int fragmentStart = 0; *************** *** 67,77 **** boolean inSingleQuotes = false; boolean inDoubleQuotes = false; ! char[] aChars = query.toCharArray(); ! int aLen = aChars.length; ! for (int i = 0; i < aLen; ++i) { ! char c = aChars[i]; switch (c) { --- 67,75 ---- boolean inSingleQuotes = false; boolean inDoubleQuotes = false; ! for (int i = 0; i < query.length(); ++i) { ! char c = query.charAt(i); switch (c) { *** ./org/postgresql/jdbc2/AbstractJdbc2Connection.java Fri Oct 14 11:35:27 2005 --- ../postgresql-jdbc-8.0-313.src original/./org/postgresql/jdbc2/AbstractJdbc2Connection.java Tue Jun 21 15:11:52 2005 *************** *** 54,62 **** // Default statement prepare threshold. protected int prepareThreshold; - - protected boolean replaceProcessingEnabled = true; - // Connection's autocommit state. public boolean autoCommit = true; // Connection's readonly state. --- 54,59 ---- *************** *** 79,85 **** //standard out if no other printwriter is set // XXX revisit: need a debug level *per connection*. - replaceProcessingEnabled = !"false".equalsIgnoreCase(info.getProperty("replaceProcessingEnabled")); int logLevel = 0; try --- 76,81 ---- *** ./org/postgresql/jdbc2/AbstractJdbc2Statement.java Fri Oct 14 11:33:44 2005 --- ../postgresql-jdbc-8.0-313.src original/./org/postgresql/jdbc2/AbstractJdbc2Statement.java Mon Oct 3 12:26:36 2005 *************** *** 106,112 **** public AbstractJdbc2Statement (AbstractJdbc2Connection c, int rsType, int rsConcurrency) throws SQLException { this.connection = c; - replaceProcessingEnabled = c.replaceProcessingEnabled; this.preparedQuery = null; this.preparedParameters = null; this.lastSimpleQuery = null; --- 106,111 ---- *************** *** 117,123 **** public AbstractJdbc2Statement(AbstractJdbc2Connection connection, String sql, boolean isCallable, int rsType, int rsConcurrency) throws SQLException { this.connection = connection; - replaceProcessingEnabled = connection.replaceProcessingEnabled; this.lastSimpleQuery = null; String parsed_sql = replaceProcessing(sql); --- 116,121 ---- --Apple-Mail-1--868310100--