473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C functions quicker than Plpgsql?


Hi all,

Given a stored procedure that runs entirely within the database (e.g. loop
through a few rows of table A, apply "some function" and create a few rows in
table B) - I am wondering what the performance benefits are of implementing
such a
function in C using the SPI vs plpgsql.

Obviously if "some function" is fairly involved then there may be an
advantage by coding it in C - but if it isn't will the C function
still execute faster?

as an unrealistic simple example...

create function test() returns void as '
declare
r record;
begin
for r in select * from table_a where x > 500 loop
insert into table_b (id) values (a.id);
end loop;
return;
end;
' language plpgsql;

now if i write it in C instead, what do i gain performance-wise?

thanks for any light you can shed on this...

Cheers,
Martin
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #1
1 1469
Martin Hart writes:
I am wondering what the performance benefits are of implementing such a
function in C using the SPI vs plpgsql.


plpgsql is itself implemented in C using SPI. So you do the math.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rajesh Kumar Mallah | last post by:
Hi, profile_row profile_master%ROWTYPE; in a plpgsql function gives the error below tradein_clients=# SELECT general.create_accounts(); WARNING: plpgsql: ERROR during compile of...
4
by: Nigel J. Andrews | last post by:
I'm considering writing some functions in C. This is a collection of approximately 230 functions, mostly in plpgsql at the moment. Number of lines of plpgsql is approximately 6500 but that'll...
4
by: anorakgirl | last post by:
hi, i'm writing some plpgsql functions which use a temporary table, and i've read the FAQ and am using EXECUTE to create and insert into my table to avoid errors caused by postgres caching the...
14
by: Karl O. Pinc | last post by:
Hi, Thought perhaps some other eyes than mine can tell if I'm doing something wrong here or if there's a bug somewhere. I've never passed a ROWTYPE varaible to a function but I don't see where...
2
by: Florian G. Pflug | last post by:
Hi I faintly remember that I once stumbled upon a way to declare variadic functions (functions that take a variable number of arguments) in plpgsql - but I just searched the docs and can't find...
0
by: sripathy sena | last post by:
Hi, I am trying to install OPenacs with postgres 7.4.3 as the database. The openacs requires plpgsql to be installed. When I try to do this by running "CREATELANG plpgsql template1". I get a...
1
by: Karl O. Pinc | last post by:
FYI, mostly. But I do have questions as to how to write code that will continue to work in subsequent postgresql versions. See code below. begintest() uses EXIT to exit a BEGIN block from...
5
by: Robert Fitzpatrick | last post by:
Can someone point me to some more information or perhaps show an example of returning a recordset from a plpgsql function. I'd like to send an argument or arguments to the function, do some queries...
5
by: Matthew Metnetsky | last post by:
I'm trying to write two custom recursive functions: one that selects, and the other that selects/updates. I've been looking around the internet for examples for they're so limiting and...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.