logoalt Hacker News

array_key_firstyesterday at 5:00 PM1 replyview on HN

DB queries do get pre compiled and cached if you use prepared statements. This is why you should always use prepared statements if you can.


Replies

kbolinoyesterday at 5:31 PM

It is not always necessary to explicitly use prepared statements, though. For example, the pgx library for Go [1] and the psycopg3 library for Python [2] will automatically manage prepared statements for you.

[1]: https://pkg.go.dev/github.com/jackc/pgx/v5#hdr-Prepared_Stat...

[2]: https://www.psycopg.org/psycopg3/docs/advanced/prepare.html