当二进制字段位于 where 子句中时如何运行解释查询 [英] How to run a explain query when a binary field is in the where clause

查看:26
本文介绍了当二进制字段位于 where 子句中时如何运行解释查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 EXPLAIN 在 MySQL 上检查以下查询的查询计划.

I need to check the query plan for the following query on MySQL using EXPLAIN.

但问题是 where 子句中的列是 binary(16).它是一个向导.

But the problem is the column in the where clause is binary(16). Its a guid.

explain select `title`,`ttext` 
FROM ptip inner join user on user.id = ptip.userId
where ptip.titlehash = <whatever value>

这里的 titlehash 是 binary(16) 并且查询给出以下错误:

Here the titlehash is binary(16) and the query gives the following error:

'在阅读常量表后发现不可能在哪里'

'Impossible WHERE noticed after reading const tables'

我尝试使用;where ptip.titlehash = BINARY('24dwdfsdf') 但还是一样;

I tried using; where ptip.titlehash = BINARY('24dwdfsdf') but still the same;

你如何运行上述查询?

推荐答案

好的,我终于解决了;

SET @hs = (SELECT titlehash FROM ptip WHERE id = 5673);
EXPLAIN SELECT `title`,`ttext` 
FROM ptip INNER JOIN USER ON user.id = ptip.userId
WHERE ptip.titlehash  = @hs

我将值放入@hs 变量中,然后用于解释.幸运的是,解释命令只解释了选择.它不关心 SET 操作并将@hs 变量视为一个值

I put the value in the @hs variable and then use for explain. Fortunately the explain command explains the select only. It doesn't care about the SET operation and treat the @hs variable as just a value

这篇关于当二进制字段位于 where 子句中时如何运行解释查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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