pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
7+ messages / 4 participants
[nested] [flat]

* Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-28 14:30  Andreas Joseph Krogh <andreak@officenet.no>
  0 siblings, 2 replies; 7+ messages in thread

From: Andreas Joseph Krogh @ 2007-06-28 14:30 UTC (permalink / raw)
  To: pgsql-sql

Hi all.
Anybody knows if the following query will use an index-scan in PG-8.3?

SELECT name FROM person WHERE name LIKE 'and%';

I know this works in "C"-locale, but I need it with UTF-8, probably the rest 
of the world soon too...

-- 
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-28 14:43  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Andreas Joseph Krogh <andreak@officenet.no>
  1 sibling, 0 replies; 7+ messages in thread

From: Pavel Stehule @ 2007-06-28 14:43 UTC (permalink / raw)
  To: Andreas Joseph Krogh <andreak@officenet.no>; +Cc: pgsql-sql

Hello,

it's possible. You have to use varchar_pattern_ops:

CREATE INDEX like_index ON person(name varchar_pattern_ops);

Regards
Pavel Stehule

2007/6/28, Andreas Joseph Krogh <andreak@officenet.no>:
> Hi all.
> Anybody knows if the following query will use an index-scan in PG-8.3?
>
> SELECT name FROM person WHERE name LIKE 'and%';
>
> I know this works in "C"-locale, but I need it with UTF-8, probably the rest
> of the world soon too...
>
> --
> Andreas Joseph Krogh <andreak@officenet.no>
> Senior Software Developer / Manager
> ------------------------+---------------------------------------------+
> OfficeNet AS            | The most difficult thing in the world is to |
> Karenslyst Allé 11      | know how to do a thing and to watch         |
> PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
> 0214 Oslo               | comment.                                    |
> NORWAY                  |                                             |
> Tlf:    +47 24 15 38 90 |                                             |
> Fax:    +47 24 15 38 91 |                                             |
> Mobile: +47 909  56 963 |                                             |
> ------------------------+---------------------------------------------+
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-28 15:20  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andreas Joseph Krogh <andreak@officenet.no>
  1 sibling, 1 reply; 7+ messages in thread

From: Tom Lane @ 2007-06-28 15:20 UTC (permalink / raw)
  To: Andreas Joseph Krogh <andreak@officenet.no>; +Cc: pgsql-sql

Andreas Joseph Krogh <andreak@officenet.no> writes:
> Anybody knows if the following query will use an index-scan in PG-8.3?
> SELECT name FROM person WHERE name LIKE 'and%';
> I know this works in "C"-locale, but I need it with UTF-8,

"C locale" and "UTF8" are entirely orthogonal things.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-28 15:30  Andreas Joseph Krogh <andreak@officenet.no>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 7+ messages in thread

From: Andreas Joseph Krogh @ 2007-06-28 15:30 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

On Thursday 28 June 2007 17:20:56 Tom Lane wrote:
> Andreas Joseph Krogh <andreak@officenet.no> writes:
> > Anybody knows if the following query will use an index-scan in PG-8.3?
> > SELECT name FROM person WHERE name LIKE 'and%';
> > I know this works in "C"-locale, but I need it with UTF-8,
>
> "C locale" and "UTF8" are entirely orthogonal things.
>
> 			regards, tom lane

I had the impression that LIKE-queries of type LIKE '123%' couldn't use an 
index if encoding was UTF-8. I was wrong obviously. The varchar_pattern_ops 
suggested by Pavel did the trick for me.

Tom: Can you comment on, very short, if the discussion on HACKERS with 
title "like/ilike improvements" will improve LIKE queries like this?

Anybody knows if queries of type "LIKE '%234%'" ever will be able to use 
indexes, and if someone is working on it? I'm sure I'm not the only one who 
would very much appreciate it:-)

-- 
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-28 15:54  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andreas Joseph Krogh <andreak@officenet.no>
  1 sibling, 1 reply; 7+ messages in thread

From: Tom Lane @ 2007-06-28 15:54 UTC (permalink / raw)
  To: Andreas Joseph Krogh <andreak@officenet.no>; +Cc: pgsql-sql

Andreas Joseph Krogh <andreak@officenet.no> writes:
> Anybody knows if queries of type "LIKE '%234%'" ever will be able to use
> indexes, and if someone is working on it?

Perhaps you are looking for full text search (contrib/tsearch2)?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-28 16:14  Andreas Joseph Krogh <andreak@officenet.no>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Andreas Joseph Krogh @ 2007-06-28 16:14 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Tom Lane <tgl@sss.pgh.pa.us>

On Thursday 28 June 2007 17:54:59 Tom Lane wrote:
> Andreas Joseph Krogh <andreak@officenet.no> writes:
> > Anybody knows if queries of type "LIKE '%234%'" ever will be able to use
> > indexes, and if someone is working on it?
>
> Perhaps you are looking for full text search (contrib/tsearch2)?

No, I know very well that tsearch2 exists, and use it, but it doesn't 
handle "contains" queries.

-- 
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?
@ 2007-06-29 07:31  Oleg Bartunov <oleg@sai.msu.su>
  parent: Andreas Joseph Krogh <andreak@officenet.no>
  1 sibling, 0 replies; 7+ messages in thread

From: Oleg Bartunov @ 2007-06-29 07:31 UTC (permalink / raw)
  To: Andreas Joseph Krogh <andreak@officenet.no>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql

On Thu, 28 Jun 2007, Andreas Joseph Krogh wrote:

> Anybody knows if queries of type "LIKE '%234%'" ever will be able to use
> indexes, and if someone is working on it? I'm sure I'm not the only one who
> would very much appreciate it:-)
>

This is quite easily could be done with tsearch using substring dictionary.
Search archives !

 	Regards,
 		Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2007-06-29 07:31 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-28 14:30 Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ? Andreas Joseph Krogh <andreak@officenet.no>
2007-06-28 14:43 ` Pavel Stehule <pavel.stehule@gmail.com>
2007-06-28 15:20 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-06-28 15:30   ` Andreas Joseph Krogh <andreak@officenet.no>
2007-06-28 15:54     ` Tom Lane <tgl@sss.pgh.pa.us>
2007-06-28 16:14       ` Andreas Joseph Krogh <andreak@officenet.no>
2007-06-29 07:31     ` Oleg Bartunov <oleg@sai.msu.su>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox