Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdbcq-0002Ka-7f for pgsql-jdbc@arkaria.postgresql.org; Fri, 13 Nov 2020 16:08:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdbco-0000oo-NY for pgsql-jdbc@arkaria.postgresql.org; Fri, 13 Nov 2020 16:08:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdbco-0000oQ-Fy for pgsql-jdbc@lists.postgresql.org; Fri, 13 Nov 2020 16:08:34 +0000 Received: from out-18.smtp.github.com ([192.30.252.201] helo=smtp.github.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdbcl-0006LG-Fn for pgsql-jdbc@lists.postgresql.org; Fri, 13 Nov 2020 16:08:33 +0000 Received: from github.com (hubbernetes-node-0edf29e.va3-iad.github.net [10.48.113.44]) by smtp.github.com (Postfix) with ESMTPA id 69A78340F9A for ; Fri, 13 Nov 2020 08:08:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1605283709; bh=4tTVtwE7T+wDcoqNYG2safFgpynyH2FoWFTV3sKNjaQ=; h=Date:From:To:Subject:From; b=N/sV9P4wZm+a8Frb5OotgXSgvECVPEHz824zmq+OyogyuXw+zOHoPHbc24tdMBbcu 8ANAji1P/HRyYGx5kzxqbzSJcLfcatf60XEel2sMJAKQ9r+UFxccF1m4dYUAapXywG nWk6UpYY+0no9W70uMmIc8YmdM4p/39gAxvk157M= Date: Fri, 13 Nov 2020 08:08:29 -0800 From: Dave Cramer To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] ff22a3: feat: implement adaptive fetching (#1718) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Branch: refs/heads/master Home: https://github.com/pgjdbc/pgjdbc Commit: ff22a3c31bb423b08637c237cb2e5bc288008e18 https://github.com/pgjdbc/pgjdbc/commit/ff22a3c31bb423b08637c237cb2e5bc288008e18 Author: Dave Cramer Date: 2020-11-13 (Fri, 13 Nov 2020) Changed paths: M README.md M docs/documentation/head/connect.md M pgjdbc/src/main/java/org/postgresql/PGConnection.java M pgjdbc/src/main/java/org/postgresql/PGProperty.java M pgjdbc/src/main/java/org/postgresql/PGStatement.java M pgjdbc/src/main/java/org/postgresql/core/PGStream.java M pgjdbc/src/main/java/org/postgresql/core/QueryExecutor.java M pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java A pgjdbc/src/main/java/org/postgresql/core/v3/adaptivefetch/AdaptiveFetchCache.java A pgjdbc/src/main/java/org/postgresql/core/v3/adaptivefetch/AdaptiveFetchCacheEntry.java M pgjdbc/src/main/java/org/postgresql/ds/common/BaseDataSource.java M pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java M pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java M pgjdbc/src/main/java/org/postgresql/jdbc/PgStatement.java A pgjdbc/src/test/java/org/postgresql/core/v3/adaptivefetch/AdaptiveFetchCacheTest.java M pgjdbc/src/test/java/org/postgresql/jdbc/AbstractArraysTest.java M pgjdbc/src/test/java/org/postgresql/test/jdbc2/Jdbc2TestSuite.java A pgjdbc/src/test/java/org/postgresql/test/jdbc42/AdaptiveFetchSizeTest.java M pgjdbc/src/test/java/org/postgresql/test/jdbc42/Jdbc42TestSuite.java Log Message: ----------- feat: implement adaptive fetching (#1718) * feat: implementation of adaptive fetching Implementation of adaptive fetching logic during process of fetching result set. Change adds three new properties used with adaptive fetching: - adaptiveFetch - use to enable/disable work of adaptive fetching - adaptiveFetchMinimum - use to define minimum size computed during adaptive fetching - adaptiveFetchmaximum - use to define maximum size computed during adaptive fetching Adaptive fetching is used to compute fetch size to fully use size defined by maxResultBuffer. Computing is made by dividing maxResultBuffer size by max row result size noticed so far. Each query have seperate adaptive fetch size computed, but same queries have it shared. If adaptive fetch is turned on, first fetch is going to be made with defaultRowFetchSize, next fetching of resultSet will be made with computed adaptive fetch size. If adaptive fetch is turned on during fetching, then first fetching made by ResultSet will be made with defaultRowFetchSize, next will use computed adaptive fetch size. Additionally, resultSet have new method - getLastUsedFetchSize to get fetch size used during last fetching. If adaptive fetching is turned on, then getFetchSize will return lastUsedFetchSize. Property adaptiveFetch need properties defaultRowFetchSize and maxResultBuffer to work. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Fix of type start in HashMap in constructor of AdaptiveFetchQueryMonitoring Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Documentation update in file connect.md Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching More explanation for setMaxRowSize method in PGStream class. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Commit to add: - unit tests for AdaptiveFetchQueryMonitoring class; - some style fixes (removing extra spaces, simpler code in setMaxRowSize method in PGStream class). Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Commit to add: - integration tests for adaptive fetching process; - change casting to from primitive types to Wrapper classes in AdaptiveFetchQueryMonitoringTest. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Change in AdaptiveFetchSizeTest: - is using PreparedStatement during tests now; - added assume to check if preferQueryMode is not Simple; - new method to open connection and creating table to remove code repetitiveness. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Commit to add explanation about adaptive fetching process in AdaptiveFetchQueryMonitoring class. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Style changes in code of adaptive fetch: - change usage of "BOOLEAN.true" to "true"; - change usage of "localAdaptiveFetch == true" to "localAdaptiveFetch"; - removed swallowing all exceptions in QueryExecutorImpl methods; - renamed "AdaptiveFetchQueryMonitoring" class to "AdaptiveFetchCache"; - renamed "AdaptiveFetchQueryInfo" class to "AdaptiveFetchCacheEntry"; - change of variables names for consistent naming in AdaptiveFetchCache; - change of variable names to show unit for variables containing maximum row size; - new methods in AdaptiveFetchCacheEntry class for increment/decrement counter; - change in comments to be consistent with existing comments. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Commit to add: - missing methods for EncodingConnection in AbstractArraysTest.java; - checking for NULL objects in adaptive fetch logic code in QueryExecutorImpl and PgResultSet; - added NonNull annotation for Query parameters for methods in AdaptiveFetchCache. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Commit changed: - swapped descriptions for ADAPTIVE_FETCH_MAXIMUM and ADAPTIVE_FETCH_MINIMUM in PGProperty enum; - changed the comment for ADAPTIVE_FETCH property in PGProperty enum; - removed the redundant comment for setAdaptiveFetch() method in PGConnection interface. Commit made for Heimdall Data's request to implement adaptive fetching. * feat: implementation of adaptive fetching Commit changed: - corrected the mistake in the comment for ADAPTIVE_FETCH property in PGProperty enum; - brought back the comment for setAdaptiveFetch() method in PGConnection interface. Commit made for Heimdall Data's request to implement adaptive fetching. Co-authored-by: Adrian Kloskowski