Solved

Table valued vs OUT function's performance in postgresql

Posted on 2014-11-25
1
234 Views
Last Modified: 2014-12-18
Hello fellow postgresql experts,

I was wandering about the opportunity to use table-valued functions vs functions returning output sets.  From your experience, which one,  assuming all indexes are in place, presents the best performance regarding :

> Concurrent accesses.  
> Handling by the optimizer
> CPU and IO execution usage.
> Locking

I would appreciate you enlighten me on the above.  Thank you for your help.
0
Comment
Question by:Racim BOUDJAKDJI
1 Comment
 
LVL 22

Accepted Solution

by:
earth man2 earned 500 total points
ID: 40465883
From the docs...
Note: The current implementation of RETURN NEXT and RETURN QUERY stores the entire result set before returning from the function, as discussed above. That means that if a PL/pgSQL function produces a very large result set, performance might be poor: data will be written to disk to avoid memory exhaustion, but the function itself will not return until the entire result set has been generated. A future version of PL/pgSQL might allow users to define set-returning functions that do not have this limitation. Currently, the point at which data begins being written to disk is controlled by the work_mem configuration variable.
 Administrators who have sufficient memory to store larger result sets
 in memory should consider increasing this parameter.

Returns table an returns setof are essentially equivalent.
If you have very large datasets then you are better of using libpq functions or cursors.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now