tcdi / plrust

A Rust procedural language handler for PostgreSQL
PostgreSQL License
1.1k stars 32 forks source link

UDF load time is high when compared to PL/PGSQL #397

Closed sriselvaraj closed 10 months ago

sriselvaraj commented 10 months ago

We are converting the UDFs from PL/PGSQL to PL/Rust. When we try to run the sql file with all the UDFs in PL/PGSQL, the UDFs are loaded very quickly where as with PL/Rust, it is taking a long time. Is this expected with PL/Rust due to the fact that the crates are pulled and rust functions are compiled? Or is it something that will be optimised in future?

eeeebbbbrrrr commented 10 months ago

Yes, it takes quite a bit of time to compile the first PL/Rust function, then subsequent functions are a little faster.

Believe it or not, we've already put a lot of effort into compilation time. For now this might be the best we can accomplish. Rust's compiler is highly parallelized, so more CPUs can speed things up. Technically tho, it's the linking phase that usually takes the most time and that's single-threaded.

We appreciate the feedback tho. We'll keep this on our radar.

sriselvaraj commented 10 months ago

Thank you for the quick reply.