by Elmar Athmer <elmar@[EMAIL PROTECTED]
>
Feb 20, 2008 at 03:40 PM
Hi
> select * from tablex where col1=5 and col2='a'
> All I am interested is if there is match or not.
If your only interested if there is at least one match, you could add
"limit 1" to the query, so the DBMS can stop iterating through the table.
i.e. select * from tablex where col1=5 and col2='a' limit 1
> Is there a better way to write the query instead of saying "select *"
> I am thinking select * might take more time.
I think the real costs are the number of tuples found (at least in
joins), not the size.
As Garlington mentioned, one selected coloumn would be enough.
So I would write this query:
select col1 from tablex where col1=5 and col2='a' limit 1
Elmar