I'm using MySQL 5.1, and I have a query that's roughly of the form:
select count(*) from mytable where a = "foo" and b = "bar";
In my program, the only thing that it checks is whether this is zero or nonzero. If I convert this into:
select exists(select * from mytable where a = "foo" and b = "bar");
is MySQL smart enough to stop searching when it hits the first one? Or is there some other way to communicate to MySQL that my intent is simply to find out if any records match this, and I don't need an exact count?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…