Re: Which index methodology is better?-
От | Heikki Linnakangas |
---|---|
Тема | Re: Which index methodology is better?- |
Дата | |
Msg-id | 472F781F.6080200@enterprisedb.com обсуждение исходный текст |
Ответ на | Which index methodology is better?- ("Chris Hoover" <revoohc@gmail.com>) |
Ответы |
Is ANALYZE transactional?
|
Список | pgsql-performance |
Chris Hoover wrote: > On this table, a customer can search by customer_id, customer_l_name, > and customer_f_name. > > Is it better to create 3 indexes, or one index on the three columns? > > I did some initial testing with index customer_test_idx(customer_id, > customer_l_name, customer_f_name) and postgres would use the index for > select * from customer where customer_f_name = 'zxy' - so the single > index will cover the three. Postgres can use the index in that case, but it's going to have to scan the whole index, which is a lot slower than looking up just the needed rows. If you do an EXPLAIN ANALYZE on that query, and compare it against "select * from customer where customer_id = 123", you'll see that it's a lot more expensive. I'd recommend having separate indexes. Having just one index probably does take less space, but the fact that you don't have to always scan all of it probably outweighs that. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
В списке pgsql-performance по дате отправления: