Re: quickest query to check a table for existance of a value in a field

Поиск
Список
Период
Сортировка
От chester c young
Тема Re: quickest query to check a table for existance of a value in a field
Дата
Msg-id 20020325214112.27370.qmail@web12705.mail.yahoo.com
обсуждение исходный текст
Ответ на quickest query to check a table for existance of a value in a field  (Shane Wright <me@shanewright.co.uk>)
Ответы Re: quickest query to check a table for existance of a value in a field  (Shane Wright <me@shanewright.co.uk>)
Список pgsql-sql
> I want a quick way to find out if there are any rows matching a
> specified value for this indexed field.  I dont care how many there
> are or what their properties are, just if there are any or not.
> 
> SELECT COUNT(c2) AS num FROM mytable WHERE c2=1234;
>
> Thanks
> Shane


Try: select 1 as yes from mytable where c2=1234 limit 1;or: select 1 as yes where exists( select 1 from mytable where
c2=1234
);

would be interesting to see differences in performance on your data


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards�
http://movies.yahoo.com/


В списке pgsql-sql по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: About EXECUTE in pl/pgsql
Следующее
От: Jan Wieck
Дата:
Сообщение: Re: call the same pl/pgsql procedure twice in the same connection