varbinary(255)
二进制字符串,对这样的字段怎么样创建最优索引,在VARCHAR(255)类型里,可以用最左前缀,如LEFT 4的DISTINCT数量最多,那么可以创建索引INDEX NAME(4),这样的。1:对于varbinary是否也适应?
2:varbinary类型的,有什么办法可以查看到明文?
二进制字符串,对这样的字段怎么样创建最优索引,在VARCHAR(255)类型里,可以用最左前缀,如LEFT 4的DISTINCT数量最多,那么可以创建索引INDEX NAME(4),这样的。1:对于varbinary是否也适应?
2:varbinary类型的,有什么办法可以查看到明文?
解决方案 »
- 用select ** as ** 更改不了表头?
- 问个varchar与字符集,编码的问题
- 急啊,请教用mysql语句怎么导入*.sql文件?
- at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1913)错误
- 一个innodb plugin的问题
- MYSQL数据导入问题
- 做MYSQL数据库同步时出错。高分在线等。不够再加分!!!
- 求教游戏同时在线人数查询
- MySQL自动备份报错
- MYSQL局域网访问慢,加入了skip-name-resolve
- 关于date的问题
- mysql的一个常见问题,Unknown column 'scene_id' in 'where clause'
varbinary的长度是字节长度,保存的是二进制字符串
a,b,c三个字段,在查询的时候有where a=100,也有where b=200,也有WHERE c=300,也有A=100 AND C=300
总之各种情况都可能有。
这样怎么样创建索引比较有效??在A,B,C都建单索引,还是建复合索引?有什么讲究么?
concatenating the values of the given columns. Indexes can be created that use only the leading part of column values, using col_name(length) syntax to specify an index prefix length: · Prefixes can be specified for CHAR, VARCHAR, BINARY, and VARBINARY columns. · BLOB and TEXT columns also can be indexed, but a prefix length must be given. · Prefix lengths are given in characters for non-binary string types and in bytes for binary string types. That is, index entries consist of the first length characters of each column value for CHAR, VARCHAR, and TEXT columns, and the first length bytes of each column value for BINARY, VARBINARY, and BLOB columns.
create index xx on table1(a)
create index xx on table1(b)
create index xx on table1(c)
create index xx on table1(a,b)
create index xx on table1(a,c)
create index xx on table1(b,c)
create index xx on table1(a,b,c)但实际中可以根据左适应原则
create index xx on table1(a)
create index xx on table1(c)create index xx on table1(b)
create index xx on table1(a,b)
create index xx on table1(a,c)create index xx on table1(b,c)
create index xx on table1(a,b,c)
但这样并不是最完善的,需要根据A,B,C中的数据分布进行优化索引。比如到底是 (a,b,c) 还是 (b,a,c) 细节上还是有不少讲究的。
比如WHERE A=100 AND B=100这样的有200次
WHERE B=200 AND C=100 100次
WHERE A=100 400次这样的话,索引就定为(A,B),这样满足了600次,只有100次不满足。我理解是否正确?