pgrx
pgrx copied to clipboard
POSIX timestamp conversion is slow
I'm currently writing an agg which uses a Timestamp as part of it's state (I'm using State = Internal).
It looks like on each state function call the timestamp is pushed through pg_sys::timestamp2tm to convert to Rust (POSIX). This is pretty slow.
For a million records I'm seeing 149ms with it the call vs. 70ms without it enabled (tested by returning a static timestamp).
Not sure what could be done here - maybe using a custom implementation which mirrors the PG one's format?
I wonder if we could find a way to have the conversion to happen on demand... So it only happened if the user used it...
Just have the pgx object be a Rust wrapper around the pg data structure and enable casting?
Then over time more functionality can be added to the pgx object as needed.
Although that would mean the pgx object couldn’t be used in threads (as they can’t call the cast, as it calls pg)
On Sat, 26 Mar 2022 at 8:03 am, Ana Hobden @.***> wrote:
I wonder if we could find a way to have the conversion to happen on demand... So it only happened if the user used it...
— Reply to this email directly, view it on GitHub https://github.com/tcdi/pgx/issues/504#issuecomment-1079432284, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJJDI6QYVBDFH55RNEFMATVBYS2XANCNFSM5RTCELZA . You are receiving this because you authored the thread.Message ID: @.***>