What happens if I create new threads from within a postgresql function? - Mailing list pgsql-general

From Seref Arikan
Subject What happens if I create new threads from within a postgresql function?
Date
Msg-id CA+4ThdrBq6euWx0MutAn4+Nw2wBADp7deHCfCV+oiQOj+f73dA@mail.gmail.com
Whole thread Raw
Responses Re: What happens if I create new threads from within a postgresql function?
Re: What happens if I create new threads from within a postgresql function?
List pgsql-general
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.

Best regards
Seref

pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: Visual query builder for PosgreSQL?
Next
From: Bruce Momjian
Date:
Subject: Re: What happens if I create new threads from within a postgresql function?