MYSQL哪种查询更快一点

WBOY
Release: 2016-06-23 14:05:56
Original
920 people have browsed it


第一种:
表1:主键为A(20位bigint类型),字段B为字符串(表2的自增ID,多个以“,”分开)
表2:记录

第二种:
记录表,字段A自增,字段B为(20位bigint类型,可重复,加索引)


假设数据都很大,为了拿到某一个20位bigint类型的数据列表,哪种设计查询快?


回复讨论(解决方案)

没看懂,建议贴出表结构,举例说明。

20位bigint,有必要那么大吗?小心 64bit Integer 事件。

20位bigint,有必要那么大吗?小心 64bit Integer 事件。
什么事件呀?没听说过,求解释
是把字符串转成BIGINT的,为了查询快一点

haowen

引用 2 楼 changjay 的回复:20位bigint,有必要那么大吗?小心 64bit Integer 事件。
什么事件呀?没听说过,求解释
是把字符串转成BIGINT的,为了查询快一点


$large_number = 922337203685477580800;
echo $large_number; //9.2233720368548E+20

真的有必要生成那么多位的数字吗?

查询快,一般加index就可以了。INT(11) 11位数字最合理,多了其实也用不上,反而消耗内存资源。

楼上们都歪了...
针对你的问题: 第二种

当然是第二种!
虽然 mysql 提供了 find_in_set 函数可以方便的从逗号分隔的串中提起成员,但函数的执行总是要花点时间的。
哪能比直接读取来的快呢?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!