Home  >  Article  >  Backend Development  >  如何样才能快速得到推荐数据

如何样才能快速得到推荐数据

WBOY
WBOYOriginal
2016-06-13 10:35:18820browse

求助:怎么样才能快速得到推荐数据
是这样的我在dx_gd_goods表里有一个字段iscom标示这一条数据是推荐数据。
在数据量少的时候
select * from dx_gd_goods where iscom=1 limit 4;
但是数据量一大,上面的SQL语句取4条数据很慢,我怎么做一下,或者说设计一下才能快点呢??

------解决方案--------------------
在 iscom 上建立索引
------解决方案--------------------
给iscom字段加索引
------解决方案--------------------
不会吧。 一个表能有两个主键? 索引多几个没什么事。
------解决方案--------------------
加索引。

主键不会有两个。

怎么说建索引划不来呢?
像你这样的数据1 0有大量重叠的值建立索引最好不过了。
------解决方案--------------------

探讨

因为推荐只有二个数据
一个是1 推存
一个是0 不推存
自我感觉建索引划不来,但是又不知道其它方法。
Statement:
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
Previous article:怎么对程序进行滤错处理Next article:函数分析