pg.ddx.io pgsql-jdbc@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Binary protocol patch v7 3+ messages / 2 participants [nested] [flat]
* Binary protocol patch v7 @ 2007-01-07 18:55 Mikko Tiihonen <mikko.tiihonen@iki.fi> 2007-01-07 20:00 ` Re: Binary protocol patch v7 Kris Jurka <books@ejurka.com> 0 siblings, 1 reply; 3+ messages in thread From: Mikko Tiihonen @ 2007-01-07 18:55 UTC (permalink / raw) To: pgsql-jdbc Hi, Just to remind you that the I updated the patches for sending receiving columns in v3 binary format are available at: http://mokki.dyndns.org/~mtiihone/postgresql/binarytransfer/ Changes since last update: - fixed handling of empty ResultSet. - fixed ArrayIndexOutOfBounds in CompositeParameterList It passes the current unit test suite and all other applications I have tried it with. I would be interested in any benchmarks. What you would hopefully see is reduced CPU load in both the backend and in the Java application. Also the network traffic should be somewhat reduced. Also, Kris, could you please try to find time to review the patch again and see what still needs to be fixed/clarified/tested before the patch can be accepted. --------------------------- I downloaded BenchmarkSQL 2.3.2 and run it against freshly installed postgres 8.2 backend. Results (best of 10 runs): Jan 7, 2007 CVS: 5891 tpmC - 100% + binaryPatches: 6531 tpmC - 110% The client and server ran on the same host. The Java client used around 25% of available cpu, backend the remaining time, IO was not a bottleneck. Benchmark setup: ---------------- PostgreSQL 8.2.0 with following modified config options: fsync=off, autovacuum=on, stats_row_level=on, redirect_stderr=on, checkpoint_segments=12, max_connections=10, max_prepared_transactions=50, shared_buffers=128MB, standard_conforming_strings=on The BenchmarkSQL was set up with 1 warehouse and 4 terminals. The following URL was used to connect to the backend: jdbc:postgresql://localhost:5432/test?binaryEncoding=true&prepareThreshold=1 Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-b105, mixed mode) Athlon64 2x2GHz, Linux 2.6.19.1 I ran "vacuumdb --all --full" between each benchmark run to get consistent results. -Mikko ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Binary protocol patch v7 2007-01-07 18:55 Binary protocol patch v7 Mikko Tiihonen <mikko.tiihonen@iki.fi> @ 2007-01-07 20:00 ` Kris Jurka <books@ejurka.com> 2007-02-19 03:03 ` Re: Binary protocol patch v7 Kris Jurka <books@ejurka.com> 0 siblings, 1 reply; 3+ messages in thread From: Kris Jurka @ 2007-01-07 20:00 UTC (permalink / raw) To: Mikko Tiihonen <mikko.tiihonen@iki.fi>; +Cc: pgsql-jdbc On Sun, 7 Jan 2007, Mikko Tiihonen wrote: > Just to remind you that the I updated the patches for sending receiving > columns in v3 binary format are available at: > http://mokki.dyndns.org/~mtiihone/postgresql/binarytransfer/ > > Also, Kris, could you please try to find time to review the patch again > and see what still needs to be fixed/clarified/tested before the patch > can be accepted. > I was actually looking at the v7 patch earlier this week, specifically looking at the conversion code. To try and throw some of the toughest test cases at it I modified the timestamp and time zone test code like k1-timestamp-test.patch. When running the tests with a build.local.properties including binaryTransfer=true and preparethreshold=1 this test fails. So I thought about ways to get more testing without having to rewrite every single regression test. I'm not suggesting committing any of this code, but it's just something I hacked together to try more cases. k2-describe-then-execute.patch issues a describe then an execute for every prepared statement so it won't need to be executed more than once to start using the binary transfer mode if we've set prepareThreshold to 1. This caused only one failure in an updatable resultset test because the results of ResultSet.refreshRow() were in binary while the ResultSet was in text. This failure doesn't concern me because without the hack the PreparedStatement is only used once and won't trigger a binary receive. So then I tried to k3-stmt-as-prepstmt.patch to send all Statement.executeQuery calls using a PreparedStatement to trigger binary receiver. This resulted in a deadlock in the regression tests that I did not have time to investigate. Even though this didn't work, I think it's the way to go to convince people that the new conversion code works exactly as the existing code does. I don't care how ugly it is or how slow it is, if there's a way to get the majority of our existing tests to run through the binary codepath I'd be happy to apply the patch. Kris Jurka Attachments: download all (3 files, .tar.gz)k1-timestamp-test.patch (text/plain, 1.1K) download
*** v7/org/postgresql/test/jdbc2/TimezoneTest.java Tue Sep 13 18:06:19 2005 --- v8/org/postgresql/test/jdbc2/TimezoneTest.java Fri Jan 5 00:21:31 2007 *************** *** 103,109 **** { con.createStatement().executeUpdate("INSERT INTO testtimezone(tstz,ts,t,tz,d) VALUES('2005-01-01 15:00:00 +0300', '2005-01-01 15:00:00', '15:00:00', '15:00:00 +0300', '2005-01-01')"); ! ResultSet rs = con.createStatement().executeQuery("SELECT tstz,ts,t,tz,d from testtimezone"); assertTrue(rs.next()); assertEquals("2005-01-01 15:00:00+03", rs.getString(1)); --- 103,111 ---- { con.createStatement().executeUpdate("INSERT INTO testtimezone(tstz,ts,t,tz,d) VALUES('2005-01-01 15:00:00 +0300', '2005-01-01 15:00:00', '15:00:00', '15:00:00 +0300', '2005-01-01')"); ! PreparedStatement ps = con.prepareStatement("SELECT tstz,ts,t,tz,d from testtimezone"); ! ResultSet rs = ps.executeQuery(); ! rs = ps.executeQuery(); assertTrue(rs.next()); assertEquals("2005-01-01 15:00:00+03", rs.getString(1));k2-describe-then-execute.patch (text/plain, 882B) download
diff -rcN v7/org/postgresql/jdbc2/AbstractJdbc2Statement.java v8a/org/postgresql/jdbc2/AbstractJdbc2Statement.java *** v7/org/postgresql/jdbc2/AbstractJdbc2Statement.java Thu Jan 4 20:49:32 2007 --- v8a/org/postgresql/jdbc2/AbstractJdbc2Statement.java Sun Jan 7 11:43:38 2007 *************** *** 451,456 **** --- 451,461 ---- if (concurrency != ResultSet.CONCUR_READ_ONLY) flags |= QueryExecutor.QUERY_NO_BINARY_TRANSFER; + + int flags2 = flags | QueryExecutor.QUERY_DESCRIBE_ONLY; + StatementResultHandler handler2 = new StatementResultHandler(); + connection.getQueryExecutor().execute(queryToExecute, queryParameters, handler2, 0, 0, flags2); + StatementResultHandler handler = new StatementResultHandler(); result = null; connection.getQueryExecutor().execute(queryToExecute,^ permalink raw reply [nested|flat] 3+ messages in threadk3-stmt-as-prepstmt.patch (text/plain, 1007B) download
diff -rc v8a/org/postgresql/jdbc2/AbstractJdbc2Statement.java v8/org/postgresql/jdbc2/AbstractJdbc2Statement.java *** v8a/org/postgresql/jdbc2/AbstractJdbc2Statement.java Sun Jan 7 11:43:38 2007 --- v8/org/postgresql/jdbc2/AbstractJdbc2Statement.java Fri Jan 5 11:08:33 2007 *************** *** 229,234 **** --- 229,239 ---- */ public java.sql.ResultSet executeQuery(String p_sql) throws SQLException { + PreparedStatement ps = connection.prepareStatement(p_sql); + ResultSet rs = ps.executeQuery(); + ps.close(); + return rs; + /* if (preparedQuery != null) throw new PSQLException(GT.tr("Can''t use query methods that take a query string on a PreparedStatement."), PSQLState.WRONG_OBJECT_TYPE); *************** *** 241,246 **** --- 246,252 ---- PSQLState.TOO_MANY_RESULTS); return (ResultSet)result.getResultSet(); + */ } /*
* Re: Binary protocol patch v7 2007-01-07 18:55 Binary protocol patch v7 Mikko Tiihonen <mikko.tiihonen@iki.fi> 2007-01-07 20:00 ` Re: Binary protocol patch v7 Kris Jurka <books@ejurka.com> @ 2007-02-19 03:03 ` Kris Jurka <books@ejurka.com> 0 siblings, 0 replies; 3+ messages in thread From: Kris Jurka @ 2007-02-19 03:03 UTC (permalink / raw) To: Mikko Tiihonen <mikko.tiihonen@iki.fi>; +Cc: pgsql-jdbc On Sun, 7 Jan 2007, Kris Jurka wrote: > On Sun, 7 Jan 2007, Mikko Tiihonen wrote: > >> Just to remind you that the I updated the patches for sending receiving >> columns in v3 binary format are available at: >> http://mokki.dyndns.org/~mtiihone/postgresql/binarytransfer/ >> > > I was actually looking at the v7 patch earlier this week, specifically > looking at the conversion code. To try and throw some of the toughest test > cases at it I modified the timestamp and time zone test code like > k1-timestamp-test.patch. When running the tests with a > build.local.properties including binaryTransfer=true and preparethreshold=1 > this test fails. > > So I thought about ways to get more testing without having to rewrite every > single regression test. I'm not suggesting committing any of this code, but > it's just something I hacked together to try more cases. > With the attached patch and binaryTransfer=true and preparethreshold=1 in build.local.properties I was able to run the regression tests completely and got a number of failures. 1) DatabaseMetaData creates ResultSets by sometimes pulling raw bytes out of another ResultSet, so it needs to also pass the binary flag to the new ResultSet. 2) A number of failures in date/time tests. It seems to have some problems with time zones. Also, conversion to strings should result in something identical to the text format. 3) There's also a couple of fake failures due to the methodology used. testUpdateStreams and testHoldableResultSet fail only because of the changes I made. Kris Jurka Attachments:^ permalink raw reply [nested|flat] 3+ messages in threadtest-binary.patch (text/plain, 4.4K) download
Binary files origbinary/org/postgresql/core/.QueryExecutor.java.swp and binary/org/postgresql/core/.QueryExecutor.java.swp differ Binary files origbinary/org/postgresql/jdbc2/.AbstractJdbc2ResultSet.java.swp and binary/org/postgresql/jdbc2/.AbstractJdbc2ResultSet.java.swp differ diff -rcN origbinary/org/postgresql/jdbc2/AbstractJdbc2Statement.java binary/org/postgresql/jdbc2/AbstractJdbc2Statement.java *** origbinary/org/postgresql/jdbc2/AbstractJdbc2Statement.java 2007-02-18 19:37:52.000000000 -0700 --- binary/org/postgresql/jdbc2/AbstractJdbc2Statement.java 2007-02-18 19:12:04.000000000 -0700 *************** *** 233,238 **** --- 233,248 ---- throw new PSQLException(GT.tr("Can''t use query methods that take a query string on a PreparedStatement."), PSQLState.WRONG_OBJECT_TYPE); + clearWarnings(); + PreparedStatement ps = connection.prepareStatement(p_sql, resultsettype, concurrency); + ps.setMaxFieldSize(getMaxFieldSize()); + ps.setFetchSize(getFetchSize()); + ps.setFetchDirection(getFetchDirection()); + ResultSet rs = ps.executeQuery(); + // ps.close(); + return rs; + + /* if (!executeWithFlags(p_sql, 0)) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); *************** *** 241,246 **** --- 251,257 ---- PSQLState.TOO_MANY_RESULTS); return (ResultSet)result.getResultSet(); + */ } /* *************** *** 451,456 **** --- 462,472 ---- if (concurrency != ResultSet.CONCUR_READ_ONLY) flags |= QueryExecutor.QUERY_NO_BINARY_TRANSFER; + + int flags2 = flags | QueryExecutor.QUERY_DESCRIBE_ONLY; + StatementResultHandler handler2 = new StatementResultHandler(); + connection.getQueryExecutor().execute(queryToExecute, queryParameters, handler2, 0, 0, flags2); + StatementResultHandler handler = new StatementResultHandler(); result = null; connection.getQueryExecutor().execute(queryToExecute, diff -rcN origbinary/org/postgresql/test/jdbc2/ConnectionTest.java binary/org/postgresql/test/jdbc2/ConnectionTest.java *** origbinary/org/postgresql/test/jdbc2/ConnectionTest.java 2005-11-23 19:31:43.000000000 -0700 --- binary/org/postgresql/test/jdbc2/ConnectionTest.java 2007-02-18 19:42:41.000000000 -0700 *************** *** 68,73 **** --- 68,74 ---- stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); assertNotNull(stat); stat.close(); + TestUtil.closeDB(conn); } /* *************** *** 88,93 **** --- 89,95 ---- stat = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); assertNotNull(stat); stat.close(); + TestUtil.closeDB(conn); } /* diff -rcN origbinary/org/postgresql/test/jdbc2/ResultSetTest.java binary/org/postgresql/test/jdbc2/ResultSetTest.java *** origbinary/org/postgresql/test/jdbc2/ResultSetTest.java 2005-11-23 19:31:43.000000000 -0700 --- binary/org/postgresql/test/jdbc2/ResultSetTest.java 2007-02-18 19:39:39.000000000 -0700 *************** *** 170,183 **** //it should apply only to binary and char/varchar columns rs.next(); assertEquals("12345", rs.getString(1)); ! assertEquals("12345", new String(rs.getBytes(1))); //max should apply to the following since the column is //a varchar column rs = stmt.executeQuery("select * from teststring"); rs.next(); assertEquals("12", rs.getString(1)); ! assertEquals("12", new String(rs.getBytes(1))); } public void booleanTests(boolean useServerPrepare) throws SQLException --- 170,183 ---- //it should apply only to binary and char/varchar columns rs.next(); assertEquals("12345", rs.getString(1)); ! // assertEquals("12345", new String(rs.getBytes(1))); //max should apply to the following since the column is //a varchar column rs = stmt.executeQuery("select * from teststring"); rs.next(); assertEquals("12", rs.getString(1)); ! // assertEquals("12", new String(rs.getBytes(1))); } public void booleanTests(boolean useServerPrepare) throws SQLException
end of thread, other threads:[~2007-02-19 03:03 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2007-01-07 18:55 Binary protocol patch v7 Mikko Tiihonen <mikko.tiihonen@iki.fi> 2007-01-07 20:00 ` Kris Jurka <books@ejurka.com> 2007-02-19 03:03 ` Kris Jurka <books@ejurka.com>
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