Respect your server's SQL cache
Optimised Access Plan etc. is cached within the server
- keyed by the exact original SQL string used
-
Compare do("insert … $id");
with do("insert … ?", undef, $id);
Without placeholders, SQL string varies each time
- so cached one is not reused
- so time is wasted creating a new access plan
- the new statement and access plan are added to cache
- so the cache fills and other statements get pushed out
- on a busy system this can lead to ‘thrashing’