Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:52:45+00:00 2026-06-08T21:52:45+00:00

I have an application written on Play Framework 1.2.4 with Hibernate(default C3P0 connection pooling)

  • 0

I have an application written on Play Framework 1.2.4 with Hibernate(default C3P0 connection pooling) and PostgreSQL database (9.1).

Recently I turned on slow queries logging ( >= 100 ms) in postgresql.conf and found some issues.

But when I tried to analyze and optimize one particular query, I found that it is blazing fast in psql (0.5 – 1 ms) in comparison to 200-250 ms in the log. The same thing happened with the other queries.

The application and database server is running on the same machine and communicating using localhost interface.

JDBC driver – postgresql-9.0-801.jdbc4

I wonder what could be wrong, because query duration in the log is calculated considering only database processing time excluding external things like network turnarounds etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:52:46+00:00Added an answer on June 8, 2026 at 9:52 pm

    Possibility 1: If the slow queries occur occasionally or in bursts, it could be checkpoint activity. Enable checkpoint logging (log_checkpoints = on), make sure the log level (log_min_messages) is ‘info’ or lower, and see what turns up. Checkpoints that’re taking a long time or happening too often suggest you probably need some checkpoint/WAL and bgwriter tuning. This isn’t likely to be the cause if the same statements are always slow and others always perform well.

    Possibility 2: Your query plans are different because you’re running them directly in psql while Hibernate, via PgJDBC, will at least sometimes be doing a PREPARE and EXECUTE (at the protocol level so you won’t see actual statements). For this, compare query performance with PREPARE test_query(...) AS SELECT ... then EXPLAIN ANALYZE EXECUTE test_query(...). The parameters in the PREPARE are type names for the positional parameters ($1,$2,etc); the parameters in the EXECUTE are values.

    If the prepared plan is different to the one-off plan, you can set PgJDBC’s prepare threshold via connection parameters to tell it never to use server-side prepared statements.

    This difference between the plans of prepared and unprepared statements should go away in PostgreSQL 9.2. It’s been a long-standing wart, but Tom Lane dealt with it for the up-coming release.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small application written in Play! which allows user registration and adding
I have application written in Zend Framework and structure is app/ application/ library/ public/
I have an application written in C#.Net (Framework 2.0 if it matters). It calls
I have an application written on top of the Zend Framework that is hosted
I have a Windows application written in C#/.NET. How can I play a specific
Hi guys so I have written my play application and all is working fine.
I have Application written with GWT 1.7. I have one page where I upload
I have application written in Visual Studio 2008 which I deploy with ClickOnce to
I have an application written using C++ Builder 5 that uses the TDocument class.
I have an application written in pure/basic Java without GUI. I have three classes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.