Re: What happens if I create new threads from within a postgresql function?

Поиск
Список
Период
Сортировка
От Seref Arikan
Тема Re: What happens if I create new threads from within a postgresql function?
Дата
Msg-id CA+4ThdoH4_FOpnViziFJ3pxF=DgZ4vdnCix8zzqO-AZt44Z8TA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: What happens if I create new threads from within a postgresql function?  (Bruce Momjian <bruce@momjian.us>)
Ответы Re: What happens if I create new threads from within a postgresql function?  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-general
Thanks Bruce,
I too think that it should be fine, as long as I make sure that the spawned
threads do not call back to originating thread and they are properly
terminated once they're finished etc.
Various messages I've seen in the list archives seem to mention that
spawning threads is a bad idea, etc etc. I just could not find a technical
discussion of why this is a bad idea. Maybe I have failed to generate the
correct search terms.
It would be great to know why and when this would be a dangerous thing  to
do.

Best regards
Seref



On Mon, Feb 18, 2013 at 2:36 PM, Bruce Momjian <bruce@momjian.us> wrote:

> On Mon, Feb 18, 2013 at 11:10:51AM +0000, Seref Arikan wrote:
> > Greetings,
> > What would happen if I create multiple threads from within a postgresql
> > function written in C?
> > I have the opportunity to do parallel processing on binary data, and I
> need to
> > create multiple threads to do that.
> > If I can ensure that all my threads complete their work before I exit my
> > function, would this cause any trouble ?
> > I am aware of postgresql's single threaded nature when executing
> queries, but
> > is this a limitation for custom multi threaded code use in C based
> functions?
> > I can't see any problems other than my custom spawn threads living
> beyond my
> > function's execution and memory/resource allocation issues, but if I can
> handle
> > them, should not I be safe?
> >
> > I believe I've seen someone applying a similar principle to use GPUs with
> > postgresql, and I'm quite interested in giving this a try, unless I'm
> missing
> > something.
>
> I think it would be fine.  I expect to be researching this soon myself:
>
>         http://wiki.postgresql.org/wiki/Parallel_Query_Execution
>
> Let me know how it works out.
>
> --
>   Bruce Momjian  <bruce@momjian.us>        http://momjian.us
>   EnterpriseDB                             http://enterprisedb.com
>
>   + It's impossible for everything to be true. +
>

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: What happens if I create new threads from within a postgresql function?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: What happens if I create new threads from within a postgresql function?