Re: Partial key usage
От | Tom Lane |
---|---|
Тема | Re: Partial key usage |
Дата | |
Msg-id | 6092.1093195158@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Partial key usage (Steve Tucknott <steve@retsol.co.uk>) |
Список | pgsql-novice |
Steve Tucknott <steve@retsol.co.uk> writes: > recno | integer | not null default > nextval('public.kah_kahxlate_recno_seq'::text) > kahcode | character(25) | not null > othercodetype | character varying(40) | not null > othercode | character varying(40) | not null > othercoden | numeric(20,0) | > Indexes: > "kah_kahxlate_cpk" primary key, btree (recno) > "ka_kahxlate_2" btree (othercodetype, othercode) > "kah_kahxlate_1" btree (kahcode, othercodetype) > What can happen is that the 'othercode' can be partial - so can be > accessed with LIKE - ie > SELECT kahCode FROM kah_kahXlate > WHERE otherCodeType = 'FRED' > AND otherCode LIKE 'ABC%'; This should be able to use an index on (othercodetype, othercode). If it's not, I would speculate that your database collation is not C (check "SHOW LC_COLLATE"). Non-C locales usually sort in an order that isn't compatible with pattern matching. You can either re-initdb in C locale, or make a specialized index using LIKE-compatible comparison operators. See the docs about specialized index operator classes. regards, tom lane
В списке pgsql-novice по дате отправления: