Thread: .so functions and SQL queries

.so functions and SQL queries

From
Guillaume Lémery
Date:
I ran some test to see how many queries PostGreSQL can handle per
seconds through the libpq library : not more than 200.

So, I was wondering if it is possible to write C function, compiled as
.so which can perform SQL queries such as SELECT or UPDATE ?

I think it could increase performance...

thanx.

Guillaume


Re: .so functions and SQL queries

From
"Gregory Wood"
Date:
> I ran some test to see how many queries PostGreSQL can handle per
> seconds through the libpq library : not more than 200.
>
> So, I was wondering if it is possible to write C function, compiled as
> .so which can perform SQL queries such as SELECT or UPDATE ?
>
> I think it could increase performance...

Care to share the specs on the system, or was that number consistent across
several setups?

Greg



Re: .so functions and SQL queries

From
Guillaume Lémery
Date:
>> I ran some test to see how many queries PostGreSQL can handle per
>> seconds through the libpq library : not more than 200.
>> [...]
>
> Care to share the specs on the system, or was that number consistent across
> several setups?
>
I made other tests today and obtain better results :
I have a program that forks itself as many times as I want (parameter)
and which connects to the base and then executes numerous times the same
fetchs (another parameter) : 3 SELECT via libpq and a call to a PLPGSQL
Function that performs 3 SELECT and 3 UPDATE.

In conclusion, PostGreSQL handles about 65 fetches/sec with 15 processes
(= 15 connections).
It means about 550 queries per second.

The postmaster has the -F -N 256 -B 4096 options
The tests are on a Bi-PIII 660 with 1GB RAM.

Are these results good for you ? Or do you think PG can do much better ?


Re: .so functions and SQL queries

From
Tom Lane
Date:
Guillaume =?ISO-8859-1?Q?L=E9mery?= <glemery@comclick.com> writes:
> So, I was wondering if it is possible to write C function, compiled as
> .so which can perform SQL queries such as SELECT or UPDATE ?

See the SPI features.  I'm not convinced this will give you any huge
performance increase, however, since you still need to get the data
in and out somehow.

            regards, tom lane