Comments (8)
When I run pgjdbc-ng under jProfile using sampling, I get this performance profile...
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.
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.
Given that the Cleanup
was showing up high, I tried disabling the housekeeper completely... this is the profile now:
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.
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.
"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.
I would be ok with having the default value of 'housekeeper' be false.
from pgjdbc-ng.
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.
I consider this issue closed with the merge from @kdubb.
from pgjdbc-ng.
Related Issues (20)
- Avoid use of prepared statement and still use placeholders
- Allow underscore _ in the host name of a postgres database HOT 1
- Issue with RDS IAM Role Authentication
- update protocol properties at the time of connection creation
- What's the status and direction of the project? HOT 17
- Does it support MATCH_RECOGNIZE? HOT 4
- SCRAM channel binding check failed HOT 3
- Connection leak when timing out connection attempts
- Transfer to PostgreSQL Organization HOT 12
- Committer approval for transfer of copyright HOT 29
- Prepared statement already exists
- Parameter Parsing fails on concat operator in SQLText#parse
- Version upgrades HOT 1
- Execution of executeUpdate Closes Previously Acquired ResultSet
- NullPointerException on Calling getMoreResults
- Syntax Error with Statement.RETURN_GENERATED_KEYS
- Inconsistency between rs.getType() and stmt.getResultSetType()
- Inconsistent Handling of Invalid setFetchDirection Input between ResultSet and Statement
- ResultSet.beforeFirst() Unexpectedly Succeeds on TYPE_FORWARD_ONLY ResultSet
- Execution of executeUpdate Closes Previously Acquired ResultSet HOT 2
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 pgjdbc-ng.