Appropriate indices to create for these queries

Поиск
Список
Период
Сортировка
От Gerald Gutierrez
Тема Appropriate indices to create for these queries
Дата
Msg-id IIEOKIIOJMELMIFMMEBFOEILCAAA.gutz@kalador.com
обсуждение исходный текст
Список pgsql-sql
I've been looking into indices and which ones to create and I'm getting
myself a little confused. The "PostgreSQL Introduction and Concepts" book
didn't help very much. I wonder if a kind soul can give me some tips.

SELECT * FROM T1 WHERE a=1 and b='hello';

Is the appropriate index for this query:

CREATE INDEX ndx ON T1 (a, b) ?

When I was testing, it seemed that even if I created the index with only
"a", EXPLAIN told me that it would just do an index scan, seemingly
indicating that it didn't matter whether I had an "a" index, or an "a, b"
index.

How about for WHERE a=1 or b='hello' and other more complex forms? Is there
documentation that describes a variety of different queries and what kind of
indices are best?

Thanks.



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: very very slow .....
Следующее
От: "Picard, Cyril"
Дата:
Сообщение: passing null parameter to plpgsq functions