• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

H2 Database speed: file vs. tcp

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I have encountered something which I find counter-intuitive and therefor probably has a direct problematic cause. I am getting significantly slower performance from my h2 database when connected to the database directly to a file (embedded only mode) vs local server (tcp://localhost:8082). Using the exact same identical program with the only change being the url of the database there is a massive performance hit when connected straight to the file instead of through a local server. My question is, what factors could cause the database to have slowdown when accessed via embedded mode that would not be a factor when connected via a local server connection.

Thank you for your time in reading my post.

EDIT: After more testing, it seems the culprit is not the difference between file and local server connections necessarily. While connected to the local server via tcp, the program moves very fast ONLY if I am also logged into the database in the h2 console. If I am not logged in in the h2 console, the speed of the applications connections are slow again. Hopefully someone here can explain that :-)

EDIT2: Solved this one with some help from a friend and many hours of searching. My problem was the database was closing its connection after every single query. Two solutions I found to be effective for those of you stumbling upon this post looking for answers. Firstly you can manually set your database to either delay automatic closing of connections or even make it NEVER do so. A more sophisticated approach is to use connection pooling.
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic