if there is no index on column id, then in the worst case, all 3 queries could be O(n)?[/quote]O(1), O(n), O(1)[/quote]
could you please elaborate?
select count(1231) from city;最慢;
select id from city where Id=1231;要快一些;
select id from city where Id=1231 limit 1;最快。
if there is no index, say id=1231 is the last record, IMHO, does mysql have to loop through all records to get the there? that why I thought the worst time complexity could be n. Why do you think the first and the third queries can be done in O(1)?
thx!