agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Sonnenberg-Carstens, Stefan <ssonnenberg@ophardt.com>
To: Mark Teper <mark.teper@gmail.com>
To: pgsql-sql@lists.postgresql.org <pgsql-sql@lists.postgresql.org>
Subject: AW:
Date: Mon, 6 May 2019 08:17:46 +0000
Message-ID: <4251b7dca6bf4536b4d5a11931a83191@OPHT402P.ophardt.com> (raw)
In-Reply-To: <CAMwSyGra+i1oL0pKgCv1WeE6GeBNhJJZTJ0bGxLNqJ0SFeEsVw@mail.gmail.com>
References: <CAMwSyGra+i1oL0pKgCv1WeE6GeBNhJJZTJ0bGxLNqJ0SFeEsVw@mail.gmail.com>
Hi,
is the Python code running inside the PostgreSQL instance?
If not, the performance penalty might only get marginally better because it always involves to copy the data to the client and back again.
Mit freundlichen Grüßen
Stefan Sonnenberg-Carstens
Teamleiter Softwareentwicklung WECO / DevOps Engineer
B.Sc. Wirtschaftsinformatik
[Signatur_50-Jahre-ingo-man]
OPHARDT HYGIENE-TECHNIK GmbH + Co. KG
Lindenau 27
D - 47661 Issum
Tel: +49 2835 18-492
Fax: +49 2835 18-28492
Mail: ssonnenberg@ophardt.com<mailto:ssonnenberg@ophardt.com>
www.OPHARDT.com<http://www.ophardt.com/;
Handelsregistereintrag beim Amtsgericht Kleve:
Kommanditgesellschaft HRA 1681, Komplementärin:
OPHARDT HYGIENE-TECHNIK VerwaltungsGmbH HRB 3910
Geschäftsführer: Thomas Houcken
USt.-Identifikations-Nr.: DE813067257
CONFIDENTIALITY NOTICE:
This e-mail communication and any attachments may contain confidential and privileged information for the use
of the designated recipients named above. Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies
of the original message.
Von: Mark Teper [mailto:mark.teper@gmail.com]
Gesendet: Donnerstag, 2. Mai 2019 19:51
An: pgsql-sql@lists.postgresql.org
Betreff:
Hi,
I'm trying to build some numerical processing algorithms on Postgres Array data types. Using PL/Python I can get access to the numpy libraries but the performance is not great. A guess is that there is a lot of overhead going from Postgres -> Python List -> Numpy and back again.
I'd like to test if that's the issue, and potentially fix by creating a C extension to convert directly from Postgres Array types to Numpy Array types. I _think_ I have the C side somewhat working, but I can't get Postgres to use the transform.
What I have:
---
CREATE FUNCTION arr_to_np(val internal) RETURNS internal LANGUAGE C AS 'MODULE_PATHNAME', 'arr_to_np';
CREATE FUNCTION np_to_arr(val internal) RETURNS real[] LANGUAGE C AS 'MODULE_PATHNAME', 'np_to_arr';
CREATE TRANSFORM FOR real[] LANGUAGE plpythonu (
FROM SQL WITH FUNCTION arr_to_np(internal),
TO SQL WITH FUNCTION np_to_arr(internal)
);
CREATE FUNCTION fn (a integer[]) RETURNS integer
TRANSFORM FOR TYPE real[]
AS $$ return a $$ LANGUAGE plpythonu;
----
The problem is this produces an error that transforms for type "real" doesn't work. It doesn't seem to allow for transforms on array's as opposed to underlying types. Is it possible to tell it to apply the transform to the array?
Thanks,
Mark
Attachments:
[image/png] image001.png (9.2K, ../4251b7dca6bf4536b4d5a11931a83191@OPHT402P.ophardt.com/3-image001.png)
download | view image
Message-ID: <4251b7dca6bf4536b4d5a11931a83191@OPHT402P.ophardt.com>
Permalink: ../4251b7dca6bf4536b4d5a11931a83191@OPHT402P.ophardt.com/
Also on: postgresql.org/message-id/4251b7dca6bf4536b4d5a11931a83191@OPHT402P.ophardt.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ssonnenberg@ophardt.com, mark.teper@gmail.com, pgsql-sql@lists.postgresql.org
Subject: Re: AW:
In-Reply-To: <4251b7dca6bf4536b4d5a11931a83191@OPHT402P.ophardt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox