Comments (2)
+1 for this feature. Or is there a manual way how to count number of rows returned, by intercepting how many times next() method was called?
from datasource-proxy.
DataSourceQueryCountListener
may or may not be appropriate because it is an accumulated number by thread or global, based on the strategy.
This means, if it is thread based, the count for the ResultSet#next
becomes a total of all the ResultSet
reads for the thread(usually typical request-response lifecycle in servlet). So, if one request-response makes 3 select queries and each reads 10 records, the QueryCount
will have count=30. I think what people more interested is a read count for each query.
The manual way of achieving this is by implementing MethodExecutionListener
and reacting on the callback of ResultSet#next
.
A drawback of this approach is that you need to manage the lifecycle of ResultSet
open/close and associate the count to the resultset.
This is how I have done to get the row count in the micrometer observation for DataSource
.
https://github.com/jdbc-observations/datasource-micrometer/blob/main/datasource-micrometer/src/main/java/net/ttddyy/observation/tracing/DataSourceObservationListener.java#L205-L217
I think the best approach to the library is to add a callback specific to the ResultSet
lifecycle.
For example, every time next
is called, trigger a callback with a value that contains how many times it is called for the specific ResultSet
. (actually, r2dbc-proxy
has this callback.)
Also, need a callback when ResultSet#close
is called to receive the total count for the next
. A thing that makes it more interesting is that calling ResultSet#close
is an optional operation that Statement#close
implies the close of the ResultSet
.
(Just a memo to myself about what needs to be done to achieve this)
from datasource-proxy.
Related Issues (20)
- Properly call before/after method callback on `ProxyDataSource#getConnection`
- module-info.java HOT 2
- Add `ProxyDataSourceBuilder#buildProxy()`
- Add `ProxyJdbcObject#getProxyConfig`
- Connection is not returned to the pool if connection.getTransactionIsolation() throws an exception HOT 1
- No handling of equals method for two connection object HOT 5
- Possibility of intercepting method getConnection() if exception is thrown by original DataSource HOT 2
- equals method of ProxyLogicSupport class not working as expected. HOT 1
- Expose proxy object to method callback
- Reduce transaction Isolation level queries in ProxyDataSource with HikariCP and PostgreSQL HOT 2
- Use monotonic time to measure elapsed time in SystemStopWatch
- Failed to perform getConnection in datasource-proxy 1.10 HOT 3
- Make "AbstractQueryLogEntryCreator#chompIfEndWith" defensive for empty string
- Micrometer support HOT 2
- Got number of type instead null HOT 1
- Add SQL Format Option HOT 1
- Proxying generated keys not working with MS-SQL server data source HOT 4
- Document about Jakarta namespace support HOT 3
- Setting different names for each DataSource used by a routing DataSource HOT 3
- Support Quarkus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasource-proxy.