我已经阅读了很多有关准备好的语句的信息,在我阅读的所有内容中,没有人谈论使用它们的弊端.因此,我想知道是否有人们容易忽略的有龙"的地方?
I've been reading a lot about prepared statements and in everything I've read, no one talks about the downsides of using them. Therefore, I'm wondering if there are any "there be dragons" spots that people tend to overlook?
推荐答案Prepared语句只是经过解析和预编译的SQL语句,它仅等待提供绑定变量被执行.
Prepared statement is just a parsed and precompiled SQL statement which just waits for the bound variables to be provided to be executed.
任何执行的语句迟早都会准备(需要对其进行分析,优化,编译然后执行).
Any executed statement becomes prepared sooner or later (it need to be parsed, optimized, compiled and then executed).
一条准备好的语句只是重用了解析,优化和编译的结果.
A prepared statement just reuses the results of parsing, optimization and compilation.
通常,即使您自己不使用准备好的查询,数据库系统也会使用某种优化来节省查询准备的时间.
Usually database systems use some kind of optimization to save some time on query preparation even if you don't use prepared queries yourself.
Oracle在解析查询时首先检查库缓存,如果已经解析了相同的语句,它将使用缓存的执行计划.
Oracle, for instance, when parsing a query first checks the library cache, and if the same statement had already been parsed, it uses the cached execution plan instead.
更多推荐
使用准备好的语句有不利之处吗?
发布评论