Re: query overhead - Mailing list pgsql-performance

From Tom Lane
Subject Re: query overhead
Date
Msg-id 3893.1342196107@sss.pgh.pa.us
Whole thread Raw
In response to query overhead  (Andy Halsall <halsall_andy@hotmail.com>)
List pgsql-performance
Andy Halsall <halsall_andy@hotmail.com> writes:
> I've written an Immutable stored procedure that takes no parameters and returns a fixed value to try and determine
theround trip overhead of a query to PostgreSQL. Call to sp is made using libpq. We're all local and using UNIX domain
sockets.

> Client measures are suggesting ~150-200 microseconds to call sp and get the answer back

That doesn't sound out of line for what you're doing, which appears to
include parsing/planning a SELECT command.  Some of that overhead could
probably be avoided by using a prepared statement instead of a plain
query.  Or you could try using the "fast path" API (see libpq's PQfn)
to invoke the function directly without any SQL query involved.

Really, however, the way to make things fly is to get rid of the round
trip overhead in the first place by migrating more of your application
logic into the stored procedure.  I realize that that might require
pretty significant rewrites, but if you can't tolerate per-query
overheads in the 100+ usec range, that's where you're going to end up.

If you don't like any of those answers, maybe Postgres isn't the
solution for you.  You might consider an embeddable database such
as SQLLite.

            regards, tom lane

pgsql-performance by date:

Previous
From: Claudio Freire
Date:
Subject: Re: Poor performance problem with Materialize, 8.4 -> 9.1 (enable_material)
Next
From: B Sreejith
Date:
Subject: Is there a tool available to perform Data Model review, from a performance perspective?