Re: select * and select 1
Posted in 1997
Oscar, In Terms of accuracy, they both work fine. In terms of performance, in depends on whether or not the WHERE clause of the SELECT can be satisfied completely by an index. If it can, then Informix will treat it as an Index Key Only query. If you include comparisons to non-key fields then it will either treat it as Index Path or Sequential Scan (eeek). Its hard to get around the optimizer but this is one way to do it. I recommend this to my developers when the conditions are key only. Chuck Ludwigsen cludwigs@hotmail.com Oscar Goldes <ogolde@impsat1.com.ar> wrote in article <5k520v$2h8@cssun.mathcs.emory.edu>... > Hello, > An application uses frequently the construction > if exists (select * from ... where ....) > to check if some record exists. > > I have been suggested to use instead > if exists (select 1 from ... where ....) > > Two questions: > 1. are the results totally equivalent? (regarding the "exists" ) > 2. is the second form in any measurable way faster? (it seems to be) > >