Обсуждение: plpyhton

Поиск
Список
Период
Сортировка

plpyhton

От
c k
Дата:
Hello,
Does calling a pl/python function from each database connection load the python interpreter each time? what are the effects of using pl/python function in a environment where no. of concurrent connections are more and each user calls a pl/python function?

Please give the details about how pl/python functions are executed.
Thanks and regards,

CPK

Re: plpyhton

От
c k
Дата:
Hello,
Does calling a pl/python function from each database connection load the python interpreter each time? what are the effects of using pl/python function in a environment where no. of concurrent connections are more and each user calls a pl/python function?

Please give the details about how pl/python functions are executed.
Thanks and regards,

CPK

Re: [GENERAL] plpyhton

От
Joshua Tolley
Дата:
On Wed, Nov 24, 2010 at 11:56:16AM +0530, c k wrote:
> Hello,
> Does calling a pl/python function from each database connection load the
> python interpreter each time? what are the effects of using pl/python
> function in a environment where no. of concurrent connections are more and
> each user calls a pl/python function?
>
> Please give the details about how pl/python functions are executed.
> Thanks and regards,
>
> CPK

I don't know plpython terribly well, but for most PLs, calling them once in a
session loads any interpreter they require. That interpreter remains loaded
for the duration of the session. So each individual connection will load its
own interpreter, once, at the time of the first function call requiring that
interpreter. Most widely used languages also cache various bits of important
information about the functions you run, the first time you run them in a
session, to avoid needing to look up or calculate that information again when
you run the function next time.

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

Вложения

Re: [GENERAL] plpyhton

От
c k
Дата:
Thanks for your reply.
But if a database has 100+ connections then isn't loading any such interpreter consumes more memory and requires more CPU? Does all PL languages behave in the same fashion?

Regards,
CPK

On Thu, Nov 25, 2010 at 11:12 AM, Joshua Tolley <eggyknap@gmail.com> wrote:
On Wed, Nov 24, 2010 at 11:56:16AM +0530, c k wrote:
> Hello,
> Does calling a pl/python function from each database connection load the
> python interpreter each time? what are the effects of using pl/python
> function in a environment where no. of concurrent connections are more and
> each user calls a pl/python function?
>
> Please give the details about how pl/python functions are executed.
> Thanks and regards,
>
> CPK

I don't know plpython terribly well, but for most PLs, calling them once in a
session loads any interpreter they require. That interpreter remains loaded
for the duration of the session. So each individual connection will load its
own interpreter, once, at the time of the first function call requiring that
interpreter. Most widely used languages also cache various bits of important
information about the functions you run, the first time you run them in a
session, to avoid needing to look up or calculate that information again when
you run the function next time.

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkzt918ACgkQRiRfCGf1UMOFvACdH2lXcrCzbOAgX803Ujvfvw0m
LOUAoJykSFne3ybVsyabQKJQjlIm6iiQ
=8rD2
-----END PGP SIGNATURE-----


Re: [GENERAL] plpyhton

От
Joshua Tolley
Дата:
On Fri, Nov 26, 2010 at 05:28:52PM +0530, c k wrote:
> Thanks for your reply.
> But if a database has 100+ connections then isn't loading any such
> interpreter consumes more memory and requires more CPU? Does all PL
> languages behave in the same fashion?

If there are lots of connections, and each calls a plpython function (for
example), then each will load a python interpreter, and certainly that could
add up to serious memory usage. I can't speak for *every* PL; C functions
don't load any special interpreter, for instance, and I don't think there's
anything special you have to load to run SQL functions, beyond what gets
loaded anyway.

If you have problems with hundreds of connections using too much memory when
each loads an interpreter, you ought to consider getting more memory, using a
connection pooler, changing how you do things, or some combination of the
above.

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

Вложения