-
Notifications
You must be signed in to change notification settings - Fork 832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drastically increase the performance of DatabaseMetaData.getTypeInfo() #5
Conversation
When lazy loading type information in TypeInfoCache, load all information for all types in the database instead of just the requested type. This decreased the runtime of DatabaseMetaData.getTypeInfo() from ~27s to less than 1s.
This patch appears to break some basic tests. Tested with:
'master' here is a clean upstream master not any local working branch. The failure persists if I don't rebase against current master. Tested on JDK 7, Fedora 17, Pg 9.1, ant 1.8.3. Tests failing:
|
@kdubb This isn't ready to merge. Can you test and see if you can reproduce those failures? |
I just managed to reproduce them. I will fix them and update soon. My apologies for sending it prematurely. On Sep 20, 2012, at 1:31 AM, Craig Ringer notifications@github.com wrote:
|
No worries. PgJDBC seems to be surprisingly tricky to work on. |
Accidentally inverted the while logic which caused no information to be loaded instead of the wanted behavior of all information loaded
@ringerc I managed a single character typo while implementing one of the the improvements; my favorite kind! It now passes all the tests when compiling with my default JDK's (6 & 7) on OSX. I believe it also works with java source version set to 1.5 against the master |
Thanks for that. I confirm it builds on JDK 1.5. I'm currently unable to merge it because other breakage in the driver is causing it to fail to run against Pg 8.3 (possibly also other untested versions between that and tested-ok 9.1) so I have to fix that before I can test your patch against all the supported Pg versions. Why the heck did I volunteer for this again? ;-) |
Any chance this will be fixed in the near future? This issue makes developing in playframework with jpa/postgresql really slow as the entity manager factory gets created every time after changing the code which in turn causes a call to getTypeInfo that takes 8+sec on my machine. |
Hi @kdubb thanks for your pull request. Would you be able to create some unit tests for your changes? It might help get them into the main tree faster. |
I was also adding some changes to the same code in #52 |
This patch requires some work as it doesn't merge anymore. Any chance you could look at it ? |
The problem that I have with the approach of loading all the types on connection start, that it can be really very long, to fetch all the types. On the example of my staging database:
But not many databases have 23K type definitions is the catalog, so I can imagine, that in most cases this approach will bring performance benefits. Especially taking into account, that most of the production deployments are using connection pools and will preload the caches only once, when a new connection is built. Maybe it makes sense to introduce a parameter, that will instruct to preload the types? My suggestion would be something like:
Here In any case, there will be some corner cases, if somebody wants to change the |
I would think it would make sense to lazy load them ? Certainly I can't see Dave Cramer On Tue, Jun 11, 2013 at 6:26 PM, Valentine Gogichashvili <
|
Yes, I should correct myself of course, this is lazy loading, but if you load all the types the first time you access at least one of them as suggested by this commit, effectively it is start of the connection on a busy system. |
Well clearly this requires some kind of ability to turn off and on. I think your original idea is fine. With none being the default behaviour. Dave Cramer On Tue, Jun 11, 2013 at 6:37 PM, Valentine Gogichashvili <
|
When lazy loading type information in TypeInfoCache, load all information for all types in the database instead of just the requested type. This decreased the runtime of DatabaseMetaData.getTypeInfo() from ~27s to less than 1s.