Recommended place to add prepared statements

Where is the recommended place to define prepared statements? Does it make the most sense to define them in the schema file or at the service layer? Just generally I guess where is the best place to declare prepared statements? I was also just curious on the general threshold of query complexity to make creating a prepared statement worthwhile. How complex does a repeated query have to be in order to see a performance benefit from a prepared statement?
1 Reply
lelabo
lelabo12mo ago
In my understanding, prepared statements are like queries but deferred to actual execute() calls. I would treat them like my other queries... I don't see why you would treat them otherwise. I would write them where it feels right writing your queries in your actual setup. For the other part, I am not an expert but I believe it is tied to your backend... Search prepared statement performance [postgres/MySQL/SQLite]
Want results from more Discord servers?
Add your server