Forum Moderators: open
Since I do not delete any rows in the table, I have a field called 'enabled'. So when enabled=1, the row is enabled and when enabled=0, the row is flagged as disabled or deleted.
To SELECT rows from the table, I do a SELECT name FROM table WHERE enabled = '1' AND name='foo'
My question is, would it be faster if I changed the above statement to SELECT name FROM table WHERE name='foo' AND enabled = '1'
Is it faster if I grab all the enabled rows first and then look for the specific name or is it faster if I select the name first and then the enabled.
The table has about a million entries. Both fields are indexed. The enabled is an INT type and name is a varchar.
DB is MySQL
Language is PHP 4 on Linux
TIA
[edited by: HoboTraveler at 9:45 am (utc) on Jan. 16, 2007]
Be sure you have an index on the Enabled column.
If the search is too frecuent and intensive, consider an index in both "name"+"enabled" columns.