Re: Accessing Database Data from C Function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Accessing Database Data from C Function
Дата
Msg-id 9970.1155182501@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Accessing Database Data from C Function  ("Jeffrey Bigham" <jbigham@cs.washington.edu>)
Список pgsql-general
"Jeffrey Bigham" <jbigham@cs.washington.edu> writes:
> I also have some vague understanding that C might be faster.  I hope I'm
> not opening a can-of-worms, but is C actually faster?

C should theoretically be faster than any of the alternatives you
mention, all else being equal (eg, you are implementing the identical
algorithm in each language).  Whether the difference is enough to notice
is another question --- for example, if effectively all the runtime is
spent inside SQL queries, shaving a few microseconds off the time it
takes you to issue the queries isn't going to improve your life.
You also have to consider the larger effort you'll need to put into
coding in C ... it's a pretty low-level language by any modern standard.
That effort might more profitably be spent elsewhere, eg improving the
SQL queries themselves.

My advice is don't code in C until it's clear you have to.  If you can
prototype in plpgsql or plperl or pl-your-favorite-language, do that
first and get it working; and then recode in C if the performance is
so bad you can't stand it (and you can prove that the cycles are
actually spent in your PL code and not somewhere else like the SQL
engine).  About the only time I'd not do it that way is if my problem
involves data structures too complex to express nicely in
my-favorite-pl or if I need access to low-level database details that
aren't exposed by my-favorite-pl.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Connection string
Следующее
От: "Harpreet Dhaliwal"
Дата:
Сообщение: Re: Connection string