Git Product home page Git Product logo

Comments (8)

brettwooldridge avatar brettwooldridge commented on May 28, 2024

When I run pgjdbc-ng under jProfile using sampling, I get this performance profile...

screen shot 2014-01-20 at 3 13 24 pm

This indicates that the created Cleanup task is responsible for the majority of the overhead, followed closely by the regular expressions used in the SQLText.parse() code.

from pgjdbc-ng.

kdubb avatar kdubb commented on May 28, 2024

This stems first and foremost from a principal difference between the 'classic' driver and 'ng'. In 'ng' a prepared statement is just that, prepared on the server. In 'classic' this doesn't happen. Prepare it once and execute multiple times would be the proper way to do it in 'ng'.

The regex time is something to look at as running a regex (no matter how complicated) against an empty string should be nearly free.

from pgjdbc-ng.

brettwooldridge avatar brettwooldridge commented on May 28, 2024

Given that the Cleanup was showing up high, I tried disabling the housekeeper completely... this is the profile now:

screen shot 2014-01-20 at 3 45 51 pm

The expensive part of Cleanup is creating the Exception here:

this.allocationStackTrace = new Exception().getStackTrace();

Turns out this is only used if logLeaks is true. I made a local change that only captures the stack trace if logLeaks is true. Unfortunately, there is no way to disable logging leaks from the "outside", so I couldn't actually test it easily ... I just turned off the housekeeper for my test. But it seems logging leaks should be optional (and false by default) with a setter on PGDataSource.

from pgjdbc-ng.

brettwooldridge avatar brettwooldridge commented on May 28, 2024

Just by not capturing the stack trace (turning off the housekeeper), and with the trivial change to getNextStatementName() (see pull request), the original test is down from 11463ms to 7868ms.

from pgjdbc-ng.

brettwooldridge avatar brettwooldridge commented on May 28, 2024

"Prepare it once and execute multiple times would be the proper way to do it in 'ng'."

Just to add a little color to that statement. While I understand that ideally that is the most efficient way to use a prepared statement, the reality is that ORM frameworks often prepare the same statement many thousands of times, assuming that the driver will "do the right thing". Hibernate is one framework that does this a lot. I am not currently a Hibernate user, but I have been in the past and ran into this behavior. A few years back, I was working at a company that used Hibernate and SQL Server with the jTDS driver, and was actually the motivating factor to contribute SQL parse-tree caching to the jTDS project. Obviously, the whole issue of prepare-time performance can be largely side-stepped with a prepared statement cache, but simple changes to the existing prepare code paths can also provide across the board speedups.

from pgjdbc-ng.

jesperpedersen avatar jesperpedersen commented on May 28, 2024

I would be ok with having the default value of 'housekeeper' be false.

from pgjdbc-ng.

brettwooldridge avatar brettwooldridge commented on May 28, 2024

I have some thoughts/questions jelling around the housekeeper. This issue is largely resolved by the prepared statement cache, but I'd like to leave it open a bit longer...

from pgjdbc-ng.

brettwooldridge avatar brettwooldridge commented on May 28, 2024

I consider this issue closed with the merge from @kdubb.

from pgjdbc-ng.

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.