News for hackers. Stuff that matters.
Re:PL/Rust 1.0: now a trusted language for Postgres by mkl95 on Sunday April 09, 2023 @01:37PM (#35504776)
> PL/Rust is a loadable procedural language that enables writing PostgreSQL functions in the Rust programming language

Use to write PostgreSQL functions in Rust. Also

> The top advantages of PL/Rust include writing natively-compiled functions to achieve the absolute best performance, access to Rust's large development ecosystem, and Rust's compile-time safety guarantees.

Re:PL/Rust 1.0: now a trusted language for Postgres by systems on Sunday April 09, 2023 @01:52PM (#35504906)
As someone who have done a lot of database development, none of these sound advantageous

Using a text oriented language like Perl with a good regexp engine might

DB performance, comes from indexes , table partitioning and in-memory tables and to compile query execution plans, so you save some time the very first you run a procedure

Re:PL/Rust 1.0: now a trusted language for Postgres by ixfo on Sunday April 09, 2023 @02:27PM (#35505165)
Doing in-database computation can be very advantageous for some applications, and writing those functions in Rust would be fantastic for some uses, not least for the library ecosystem. I did some work on video similarity search with in-DB search which would've certainly benefited.
Re:PL/Rust 1.0: now a trusted language for Postgres by ttfkam on Sunday April 09, 2023 @05:19PM (#35506566)
DB performance also comes from size efficiency of user-defined data types, user-defined operator functions (typically for use with those user-defined data types), etc.

Smaller, more efficient types directly translate to less disk usage and smaller indexes, both of which measurably improve database performance.

Re:PL/Rust 1.0: now a trusted language for Postgres by pjmlp on Monday April 10, 2023 @03:07AM (#35509876)
I assume PL/pg is not behind the curve in relation to PL/SQL and T-SQL for UDTs.
Re:PL/Rust 1.0: now a trusted language for Postgres by doctor_eval on Sunday April 09, 2023 @05:26PM (#35506635)
> DB performance, comes from indexes , table partitioning and in-memory tables and to compile query execution plans, so you save some time the very first you run a procedure

The network round trip to the database can also be a pretty significant performant penalty, especially when iterating over large sets.

Re:PL/Rust 1.0: now a trusted language for Postgres by samanator on Sunday April 09, 2023 @03:06PM (#35505488)
A crucial facet of optimization for computational triggers in PostgreSQL pertains to the implementation of event triggers, which enable operations to be executed in bulk (per DML statement) rather than on a per-row basis. It appears that, at present, PL/Rust has not incorporated support for event triggers. According to the documentation:

> Event Triggers and DO blocks are not (yet) supported by PL/Rust.

Re:PL/Rust 1.0: now a trusted language for Postgres by ttfkam on Sunday April 09, 2023 @05:16PM (#35506548)
Event triggers fire on DDL changes, not DML. You're thinking of statement-level triggers.

As far as event triggers and DO-blocks, that omission seems fine to me. Especially DO-blocks, which are essentially an inline code, one-off escape hatch in the middle of other SQL. Rust would not be helping any performance-sensitive critical paths in those cases.

Re:PL/Rust 1.0: now a trusted language for Postgres by doctor_eval on Sunday April 09, 2023 @05:25PM (#35506627)
True, but it’s sometimes useful for experimenting, REPL style.
Re:PL/Rust 1.0: now a trusted language for Postgres by samanator on Sunday April 09, 2023 @05:52PM (#35506818)
You're right! My mistake. I was thinking of statement triggers.

https://www.postgresql.org/docs/current/sql-createtrigger.ht...

> The REFERENCING option enables collection of transition relations

I don't see any examples of statement triggers...

Re:PL/Rust 1.0: now a trusted language for Postgres by ttfkam on Sunday April 09, 2023 @10:51PM (#35508705)
https://stackoverflow.com/a/72397774

Note the use of new_table and old_table as aliases. Instead of single records in NEW and OLD, you can select against new and old sets of records.

Re:PL/Rust 1.0: now a trusted language for Postgres by samanator on Wednesday April 12, 2023 @03:44PM (#35545649)
I understand, and I've used the old and new table aliases. But I meant that I don't see a way to use those in the PL/Rust docs.
Re:PL/Rust 1.0: now a trusted language for Postgres by pjmlp on Monday April 10, 2023 @03:05AM (#35509867)
Stored procedures are compiled to native code in any respectfull RDMS (Oracle, SQL Server, DB2,...), and I assume same applies to PostgreSQL.