Git Product home page Git Product logo

Comments (2)

fretfan avatar fretfan commented on June 21, 2024

+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.

ttddyy avatar ttddyy commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.