Re: text column indexing in UTF-8 database

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: text column indexing in UTF-8 database
Дата
Msg-id 1236906163.25953.31.camel@dell.linuxdev.us.dell.com
обсуждение исходный текст
Ответ на text column indexing in UTF-8 database  (Reece Hart <reece@harts.net>)
Ответы Re: text column indexing in UTF-8 database  (Reece Hart <reece@harts.net>)
Re: text column indexing in UTF-8 database  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Thu, 2009-03-12 at 17:15 -0700, Reece Hart wrote:
> Jeff Davis gave me a tip to use text_pattern_ops on indexes to speed up
> regexp and like; that worked beautiful. But I discovered a caveat that
> t_p_o apparently doesn't handle equality. Thus, I think I need distinct
> indexes for the 4 cases above. Right?

It looks like an index using text_pattern_ops can be used for equality
(see my test case below).

This works apparently because texteq() is defined as bitwise-equality.
Is that really correct? I was under the impression that some locales do
not obey that rule, and may consider two slightly different strings to
be equal.

Regards,
    Jeff Davis

create table a(t text);
create index a_idx on a (t text_pattern_ops);
insert into a values('foo');
set enable_seqscan='f';
analyze a;
explain analyze select * from a where t = 'foo';
               QUERY PLAN
-----------------------------------------------
 Index Scan using a_idx on a  (cost=0.00..8.27 rows=1 width=4)
   (actual time=0.009..0.010 rows=1 loops=1)
   Index Cond: (t = 'foo'::text)
 Total runtime: 0.036 ms
(3 rows)



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

Предыдущее
От: Steve Atkins
Дата:
Сообщение: Re: text column indexing in UTF-8 database
Следующее
От: Reece Hart
Дата:
Сообщение: Re: text column indexing in UTF-8 database