Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2HXn-0003q5-By for pgsql-performance@arkaria.postgresql.org; Wed, 11 Oct 2017 13:59:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2HXm-0006zM-TD for pgsql-performance@arkaria.postgresql.org; Wed, 11 Oct 2017 13:59:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e2HXl-0006xr-JR for pgsql-performance@postgresql.org; Wed, 11 Oct 2017 13:59:29 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e2HXe-0007Hy-0R for pgsql-performance@postgresql.org; Wed, 11 Oct 2017 13:59:28 +0000 Received: by mail-wm0-x235.google.com with SMTP id l68so5063706wmd.5 for ; Wed, 11 Oct 2017 06:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=46ahQf/VawTWigX9ChsOfAzB5yE+Wxo4dh/jmJEOL64=; b=tzVooOkvYTj2eHh9tkmJYMPots9+paTmygdii7ilBBOCfKjvFEtC4rYujnlWH526rh l1yXVYCdy8TvqeOAdoBRF7j7QFKyTHimJ9Zm6Eo39o+2MyPtkztxRpE2yXwuEiOSTWyo zHUBj6wBwhp3xw8IjO4uE1I1nzCnRUMJBpkK99nuWz6d2EmENFJzgFgkNyl6Tm+cNmA5 4dik/dJdi4IxsgOCoMWG/BIrBd3n9GwguIqxGRpVneCVPlgo5Kb7tkaNYsXnJ96JbtQ9 dA8chTkxoKt2Mzkm0UDkhNG6ICnvJDWP4yD4MsZM7YgdxlSYqnlZ/OR4pVZu7Cj0YT/x FVzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=46ahQf/VawTWigX9ChsOfAzB5yE+Wxo4dh/jmJEOL64=; b=L9Tk4UnUG6bhqeG7f60O5us64/ElbLqcB7sr7Hyb3XF9wEMdK2AavZfmgr6R9FCHnO yvJuNo4uOxIcLdIjs/RiEa4Ws2sPNeGxh0F6o02aBeo+88J6BdmJDKNyqPLtHazz7gGy bmtdThw7Nk2uXfiPbUFO2hZhOIaxT9KnyHU+1kPsc/O9HJmLuFbKBHjlVp22TWZXwSlX 9RsdDGvZ/EVsTwrxR79bvdGsrHXEXPowWdLR/SU4H1gCfDs05l9egPYwqMWErKT76vM5 xSrY31JFSmBsyOsIXahG+0t+rtvb8+/rY9G9Quefht+TP4wswWy6iSDGjkKPVfbC0L0p 4AhQ== X-Gm-Message-State: AMCzsaUQdI3SH/h3eB8rD1zrQmIGh7sTCxJaZ7JbWfbEiNGI4Zh467i1 yDMw/VrlTtgE3ztNWKHEDASuAMeHVlkSKjJfjEebnQ== X-Google-Smtp-Source: AOwi7QCpiJLaCkPzdcSynBG+cYCSp14FYMM3Ab1YSC/ThxPOgJl+AfnNfxgMXFeBOyyGDuLy/YKcQTSpxsfENjjPnNk= X-Received: by 10.28.209.200 with SMTP id i191mr13207437wmg.156.1507730360416; Wed, 11 Oct 2017 06:59:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.197.78 with HTTP; Wed, 11 Oct 2017 06:59:19 -0700 (PDT) In-Reply-To: <1507042486.2998.1.camel@cybertec.at> References: <1507042486.2998.1.camel@cybertec.at> From: Purav Chovatia Date: Wed, 11 Oct 2017 19:29:19 +0530 Message-ID: Subject: Re: Stored Procedure Performance To: Laurenz Albe Cc: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary="94eb2c13130e8cc3d4055b45d453" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --94eb2c13130e8cc3d4055b45d453 Content-Type: text/plain; charset="UTF-8" Thanks Laurenz, am having a look at perf. Can you pls help understand what exactly do you mean when you say "PL/pgSQL is not optimized for performance like PL/SQL". Do you mean to indicate that app firing queries/DMLs directly would be a better option as compared to putting those in Stored Procs? Regards On 3 October 2017 at 20:24, Laurenz Albe wrote: > Purav Chovatia wrote: > > I come from Oracle world and we are porting all our applications to > postgresql. > > > > The application calls 2 stored procs, > > - first one does a few selects and then an insert > > - second one does an update > > > > The main table on which the insert and the update happens is truncated > before every performance test. > > > > We are doing about 100 executions of both of these stored proc per > second. > > > > In Oracle each exec takes about 1millisec whereas in postgres its taking > 10millisec and that eventually leads to a queue build up in our application. > > > > All indices are in place. The select, insert & update are all single row > operations and use the PK. > > > > It does not look like any query taking longer but something else. How > can I check where is the time being spent? There are no IO waits, so its > all on the CPU. > > You could profile the PostgreSQL server while it is executing the > workload, > see for example https://wiki.postgresql.org/wiki/Profiling_with_perf > > That way you could see where the time is spent. > > PL/pgSQL is not optimized for performance like PL/SQL. > > Yours, > Laurenz Albe > --94eb2c13130e8cc3d4055b45d453 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks Laurenz, am having a look at perf.

Can you pls help understand what exactly do you mean when you say "= PL/pgSQL is not optimized for performance = like PL/SQL". Do you mean to indicate that app firing queries/DMLs dir= ectly would be a better option as compared to putting those in Stored Procs= ?

<= span style=3D"font-size:12.8px">Regards

On 3 October 2017 at 20:24, Lauren= z Albe <laurenz.albe@cybertec.at> wrote:
Purav Chovatia wrote:
> I come from Oracle world and we are porting all our applications to po= stgresql.
>
> The application calls 2 stored procs,=C2=A0
> - first one does a few selects and then an insert
> - second one does an update
>
> The main table on which the insert and the update happens is truncated= before every performance test.
>
> We are doing about 100 executions of both of these stored proc per sec= ond.
>
> In Oracle each exec takes about 1millisec whereas in postgres its taki= ng 10millisec and that eventually leads to a queue build up in our applicat= ion.
>
> All indices are in place. The select, insert & update are all sing= le row operations and use the PK.
>
> It does not look like any query taking longer but something else. How = can I check where is the time being spent? There are no IO waits, so its al= l on the CPU.

You could profile the PostgreSQL server while it is executing the
workload,
see for example https://wiki.postgresql.org/wiki/Profiling_with_perf

That way you could see where the time is spent.

PL/pgSQL is not optimized for performance like PL/SQL.

Yours,
Laurenz Albe

--94eb2c13130e8cc3d4055b45d453--