Skip site navigation (1) Skip section navigation (2)

Re: pl/pgsql functions outperforming sql ones?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Carlo Stonebanks <stonec(dot)register(at)sympatico(dot)ca>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: pl/pgsql functions outperforming sql ones?
Date: 2012-01-28 06:37:36
Message-ID: CAFj8pRCceGDEp1sxvMoe0oaio6P=O2nJPfs9MWgu4-+zCTdrVg@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
2012/1/27 Carlo Stonebanks <stonec(dot)register(at)sympatico(dot)ca>:
> Yes, I did test it  - i.e. I ran the functions on their own as I had always
> noticed a minor difference between EXPLAIN ANALYZE results and direct query
> calls.
>
> Interesting, so sql functions DON'T cache plans? Will plan-caching be of any
> benefit to SQL that makes no reference to any tables? The SQL is emulating
> the straight non-set-oriented procedural logic of the original plpgsql.
>

It is not necessary usually - simple SQL functions are merged to outer
query - there are e few cases where this optimization cannot be
processed and then there are performance lost.

For example this optimization is not possible (sometimes) when some
parameter is volatile

Regards

Pavel Stehule

In response to

Responses

pgsql-performance by date

Next:From: Jayashankar K BDate: 2012-01-28 17:11:53
Subject: Re: Postgress is taking lot of CPU on our embedded hardware.
Previous:From: Scott MarloweDate: 2012-01-28 03:07:31
Subject: Re: Postgress is taking lot of CPU on our embedded hardware.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group