select username from a where id=1
select username from a where id=1 limit 1说明第一个SQL也是返回一条记录..ID在数据库中是唯一值

解决方案 »

  1.   

    select username from a where id=1
    select username from a where id=1 limit 1
    如果第二句只是多了一个 limit 1 则效率几乎完全相同,理论上只差不到10个CPU周期。
    select username from a where id=1
    select username from a order by id limit 1如果你想问的是这两个,则看你的索引情况。
    如果ID是主键或索引,则效率相差并不多。
    如果ID是非索引,则第一个效率高。