Re: Sequential Scan with LIMIT

Поиск
Список
Период
Сортировка
От Curt Sampson
Тема Re: Sequential Scan with LIMIT
Дата
Msg-id Pine.NEB.4.58.0410251615150.597@angelic-vtfw.cvpn.cynic.net
обсуждение исходный текст
Ответ на Sequential Scan with LIMIT  (John Meinel <john@johnmeinel.com>)
Ответы Re: Sequential Scan with LIMIT  (Neil Conway <neilc@samurai.com>)
Re: Sequential Scan with LIMIT  (John Meinel <john@johnmeinel.com>)
Список pgsql-performance
On Sun, 24 Oct 2004, John Meinel wrote:

> I was looking into another problem, and I found something that surprised
> me. If I'm doing "SELECT * FROM mytable WHERE col = 'myval' LIMIT 1.".
> Now "col" is indexed...
> The real purpose of this query is to check to see if a value exists in
> the column,...

When you select all the columns, you're going to force it to go to the
table. If you select only the indexed column, it ought to be able to use
just the index, and never read the table at all. You could also use more
standard and more set-oriented SQL while you're at it:

    SELECT DISTINCT(col) FROM mytable WHERE col = 'myval'

cjs
--
Curt Sampson  <cjs@cynic.net>   +81 90 7737 2974   http://www.NetBSD.org
     Make up enjoying your city life...produced by BIC CAMERA

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

Предыдущее
От: Curt Sampson
Дата:
Сообщение: Re: First set of OSDL Shared Mem scalability results, some
Следующее
От: Neil Conway
Дата:
Сообщение: Re: Sequential Scan with LIMIT