cornucopia icon indicating copy to clipboard operation
cornucopia copied to clipboard

Better use of prepare and immutable bind

Open Virgiel opened this issue 2 years ago • 1 comments

I found a way to have explicit prepare, implicit prepare for client with cache and immutable bind:

// If can cache, cache-prepare else doesn't prepare
// Same as current API but whiteout implicit prepare when it can add unamortized latency
query().bind(&client, 1).await?;

// Prepare once and reuse statement, best perf when reused
query().prepare(&client).await?.bind(&client,1).await?; 

We might want to add a method to disable preparation even if it can be cached (to reduce memory cost of rare queries)

Context: https://discord.com/channels/987088069280825401/1060289763443232879

Virgiel avatar Feb 05 '23 00:02 Virgiel

I only did an overview, but this looks very promising from what I have seen. I'll take a full on look by the end of the week.

Thank you for you work on this PR, as always =]

LouisGariepy avatar Feb 08 '23 10:02 LouisGariepy