pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
lower() for varchar data by creating an index
2+ messages / 2 participants
[nested] [flat]

* lower() for varchar data by creating an index
@ 2000-05-17 07:51  Alex Guryanow <gav@nlr.ru>
  0 siblings, 1 reply; 2+ messages in thread

From: Alex Guryanow @ 2000-05-17 07:51 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I have a table called t1 with field f1 of type varchar(40):

  CREATE TABLE t1 (f1 varchar(40));

To make a case insensitive search I build the query like

   SELECT f1 FROM t1 WHERE lower( f1 ) LIKE 'alex%';

This works fine. But when I try to make an index to speed up the query using the command

     CREATE INDEX t1_f1_idx ON t1 (lower(f1));

I receive the following error:

  ERROR:  DefineIndex: function 'lower(varchar)' does not exist

Why by executing the query the function 'lower(varchar)' exists and by creating the index don't?

I use Postgres 7.0.

Best regards,
Alex





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

* Re: lower() for varchar data by creating an index
@ 2000-05-17 14:31  Mitch Vincent <mitch@venux.net>
  parent: Alex Guryanow <gav@nlr.ru>
  0 siblings, 0 replies; 2+ messages in thread

From: Mitch Vincent @ 2000-05-17 14:31 UTC (permalink / raw)
  To: gav <gav@nlr.ru>; pgsql-sql

CREATE function lower(varchar) returns text as 'lower' language 'internal'
with (iscachable);

It's a bit slower than if it was actually in the backend but it's a very
tiny difference. I spoke to Tom Lane about this, it's on the TODO list I
believe for 7.1. In the meantime the above will work great..


- Mitch

"The only real failure is quitting."


----- Original Message -----
From: Alex Guryanow <gav@nlr.ru>
To: <pgsql-sql@postgresql.org>
Sent: Wednesday, May 17, 2000 3:51 AM
Subject: [SQL] lower() for varchar data by creating an index


> Hi,
>
> I have a table called t1 with field f1 of type varchar(40):
>
>   CREATE TABLE t1 (f1 varchar(40));
>
> To make a case insensitive search I build the query like
>
>    SELECT f1 FROM t1 WHERE lower( f1 ) LIKE 'alex%';
>
> This works fine. But when I try to make an index to speed up the query
using the command
>
>      CREATE INDEX t1_f1_idx ON t1 (lower(f1));
>
> I receive the following error:
>
>   ERROR:  DefineIndex: function 'lower(varchar)' does not exist
>
> Why by executing the query the function 'lower(varchar)' exists and by
creating the index don't?
>
> I use Postgres 7.0.
>
> Best regards,
> Alex
>
>
>




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


end of thread, other threads:[~2000-05-17 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-05-17 07:51 lower() for varchar data by creating an index Alex Guryanow <gav@nlr.ru>
2000-05-17 14:31 ` Mitch Vincent <mitch@venux.net>

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