使用准备好的语句有不利之处吗?

编程入门 行业动态 更新时间:2024-10-11 17:28:24
本文介绍了使用准备好的语句有不利之处吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经阅读了很多有关准备好的语句的信息,在我阅读的所有内容中,没有人谈论使用它们的弊端.因此,我想知道是否有人们容易忽略的有龙"的地方?

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.

更多推荐

使用准备好的语句有不利之处吗?

本文发布于:2023-07-21 06:02:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1174827.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:之处   语句   不利

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!