[ADMIN] Questions regarding PL/Perl

Поиск
Список
Период
Сортировка
От Thorsten Schöning
Тема [ADMIN] Questions regarding PL/Perl
Дата
Msg-id 185240606.20170215111149@am-soft.de
обсуждение исходный текст
Список pgsql-admin
Hi all,

following situation: I have a database which stores some raw binary
data of some file format, <= 255 bytes per instance. I have a Perl
parser able to process such data and delivering a lot of individual
information regarding instances of such data, e.g. to which devices it
belongs, which type of values it contains, the values itself etc.

You can think of the data like a LibreOffice ODT-Zip, which contains
individual files which depend on the content of the document and the
version of the app the file was created with. In theory one could
extract all the contents and store them individually down to the level
of individual files like XML documents or simply store the Zip itself
and parse it with a compatible parser whenever some data is needed. In
my case I have very complex parsing rules and relationships for the
data, so I'm preferring "the store all and parse as needed" approach.
Additionally, until now I only needed very little of the content data
and only in very special circumstances. I think it's simply not worth
the effort to store it more fine grained in the DB currently.

So instead I thought of using PL/Perl with my available parser, but
have some questions which I didn't find answers for in the docs:

1. Perl interpreter/compiled code caching

The docs for "plperl.on_init" say that at least in some circumstances
interpreters created in the master are cached and provided to each new
session without any overhead. But does that include the Perl code for
individual functions created on database level? Or is that recompiled
during each invocation of a function? I hoped it would use some
approach like mod_perl does, where all created interpreters with all
their compiled code are cached and reused as needed.

2. "plperl.on_init" per database

I have multiple versions of the same application with different
versions of the database schema in use at the same time. So in theory
a parser loaded "on_init" could be incompatible for different versions
of my software. Is there some comparable mechanism per database so
that I could specify individual versions of my parser to load on
startup and benefit of the caching?

3. "PL/Perl functions cannot call each other directly."

Am I correct that this is for code created using "CREATE FUNCTION"
only? So everything shared in any way needs to be loaded by "on_init"?

4. "[...]objects are not automatically destroyed."

Does that sentence in the docs mean that "DESTROY" is not called
automatically, but the objects are removed or how do I need to
understand this? Do I need to "undef" instances in "END" on my own,
for each object ever created during a session?

My parser is OOP and heavily relies on internal objects.

5. Any additional experiences or suggestions?

Is anyone out there using PL/Perl with code like multiple packages,
objects and such? Any obvious pitfalls one should avoid? Any reasons
to simply not go that route at all?

Thanks for your input!

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow



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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [ADMIN] (auto) vacuum mysterious
Следующее
От: John Kelly
Дата:
Сообщение: [ADMIN] pg_dump: [archiver (db)] query failed: ERROR: could not access file"$libdir/postgis-2.1": No such file or directory