是否会添加不必要的比较以获得结果但是减少选择是一个好主意?
For example:
例如:
Table(id/name/code)
1/blue/1
2/red/1
4/green/1
4/../1
../../1
2552/yellow/0
would be same query to:
将是相同的查询:
$select = "SELECT * FROM table WHERE name='yellow' AND code = '0'"
than to:?
而不是:?
$select = "SELECT * FROM table WHERE name='yellow'"
I mean, i get same results, but is it same query? better? worse?
我的意思是,我得到相同的结果,但它是相同的查询?更好?更差?
1 个解决方案
#1
3
It will depend on the indexes that are associated with the table and the amount of data in the table.
它将取决于与表关联的索引以及表中的数据量。
If there's a large amount of data and you don't have an index on the name column, but an index on the code column, you would see a greater performance improvement with the code = '0'
condition.
如果存在大量数据并且您没有名称列上的索引,而是代码列上的索引,那么使用code ='0'条件会有更大的性能提升。
If you have index on each column, the distribution of data in the table will determine which index is best. If you don't have the code = '0'
condition, then that index will not be evaluated.
如果每列都有索引,则表中的数据分布将确定哪个索引最佳。如果您没有code ='0'条件,则不会评估该索引。
更多相关文章
- mysql数据库拷贝到另一个服务器上
- php怎么读取MYSQL数据到radio选项
- MySQL可视化软件Work Bench导出导入数据库
- MySQL数据导入到infobright中
- Android如何通过JDBC直连访问MySQL数据库?
- flash如何自动连接mysql数据库
- 为获得快速结果,我的查询有什么好的索引?
- Mysql存储过程、索引
- lucene 4.10 检索mysql数据库