From: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | taral(at)cyberjunkie(dot)com (Taral) |
Cc: | pgsql-general(at)postgreSQL(dot)org |
Subject: | Re: [GENERAL] Generic search |
Date: | 1998-12-04 16:17:21 |
Message-ID: | 199812041617.LAA18178@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> >hygea=> explain select * from comuni where nome = 'A%';
> >NOTICE: QUERY PLAN:
> >Index Scan using nome_comune_idx on comuni (cost=2.05 size=2 width=84)
> >^^^^^
>
> The question was about LIKE, not =. Because LIKE uses regexp-style matching and
> we have no substring index functionality, it cannot use the index. If you're
> always matching on the first character, you can do something like fulltextindex
> does and use triggers and a second (indexed) table to be able to match on the
> first character only.
If the start of the search string is anchored. From the FAQ:
When using wild-card operators like <I>LIKE</I> or <I>~,</I> indices can
only be used if the beginning of the search is anchored to the start of
the string. So, to use indices, <I>LIKE</I> searches can should not
begin with <I>%,</I> and <I>~</I>(regular expression searches) should
start with <I>^.</I>
--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Jackson, DeJuan | 1998-12-04 17:53:30 | RE: [GENERAL] How can I obtain tables' structure? |
Previous Message | José Paumard | 1998-12-04 15:59:09 | Creating a function from C code |