Solved

Table valued vs OUT function's performance in postgresql

Posted on 2014-11-25
1
245 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help decide on technology stack 3 104
Export from Postgres as fixed width file 3 150
Automate postgres backups on windows and move it to linux box 15 103
Postdresql 1 9
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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