Would adding uneeded comparisons to get the results but to reduce selection a good idea?
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:?
开发者_C百科 $select = "SELECT * FROM table WHERE name='yellow'"
I mean, i get same results, but is it same query? better? worse?
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.
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.
精彩评论