如何从准备好的陈述中获取查询计划 [英] How to get the query plan from a prepared statment

查看:68
本文介绍了如何从准备好的陈述中获取查询计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不记得曾经从控制台中看到过使用预备语句的方法,并且以某种方式认为以API中的预备语句来运行解释查询不会得到我想要的.

I don't remember ever seeing a way to use prepared statements from the console and somehow don't think running an explain query thought as a prepared statement from the API will get what I want.

这与我的这个老问题 .

我主要对MySQL感兴趣,但对其他数据库也很感兴趣.

I'm primarily interested in MySQL but would be interested in other DBs as well.

推荐答案

根据我进行的简短研究,我看不到获得此方法的方法.理想情况下,一旦提供变量,便会生成实际的执行计划.如果没有常量,查找表可以快速消除实际运行查询的情况.理想的执行计划应考虑到发生的频率.我的理解是,在准备语句以验证表达式时,MySQL至少至少用于准备执行计划.然后,当您执行它时,它会生成另一个解释计划.

According to the brief research that I conducted, I don't see a way to get it. Ideally, the real execution plan would be generated once the variables are provided. Lookup tables can quickly eliminate actually running the query if a constant is not present. The ideal execution plan would take into account the frequency of occurrence. My understanding is that MySQL at least used to prepare an execution plan when the statement is prepared in order to validate the expression. Then, when you execute it, it generates another explain plan.

我相信解释计划暂时存放在MySQL的一个表中,但使用后很快就会删除.

I believe the explain plan is temporarily housed in a table in MySQL but is quickly removed after it is used.

我建议在MySQL内部结构列表上询问.

I would suggest asking on the MySQL internals list.

祝你好运,

雅各布

Good Luck,

Jacob

这篇关于如何从准备好的陈述中获取查询计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆