Re: planning issue

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Jonathan Vanasco <postgres(at)2xlp(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: planning issue
Date: 2007-03-16 19:48:28
Message-ID: 1174074508.23455.344.camel@dogma.v10.wvs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2007-03-16 at 12:17 -0700, Joshua D. Drake wrote:
> >
> > QUERY PLAN
> > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > Seq Scan on table_a (cost=0.00..22779.68 rows=1 width=346)
> > Filter: ((id <> 10001) AND (((field_1)::text ~~* '123'::text) OR
> > ((field_2)::text ~~* 'abc'::text)))
> >
> >
> > however, i have the following indexes:
> >
> > "table_a__pkey" PRIMARY KEY, btree (id)
> > "table_a__idx__field_1" btree (field_1)
> > "table_a__idx__field_2" btree (field_2)
> >
> > can anyone offer advice to help me use the indexes on this ?
>
> create a function lower index and instead of calling ilike call ~
> lower('123')
>

To clarify a little:

CREATE INDEX table_a_lower_field_1_idx on table_a ((lower(field_1)));
CREATE INDEX table_a_lower_field_2_idx on table_a ((lower(field_2)));
SELECT
*
FROM
table_a
WHERE
id != 10001
AND
(
( lower(field_1) = '123' )
OR
( lower(field_2) = 'abc' )
)

That should be able to use your indexes correctly.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Vanasco 2007-03-16 20:16:12 Re: planning issue
Previous Message Reece Hart 2007-03-16 19:40:17 Oracle-PostgreSQL Coexistence/Interoperability (segue from PostgreSQL to Oracle)