planning issue - Mailing list pgsql-general

From Jonathan Vanasco
Subject planning issue
Date
Msg-id C32FB1DA-F767-49A6-BC7F-6D0474B9E6B8@2xlp.com
Whole thread Raw
Responses Re: planning issue  ("Joshua D. Drake" <jd@commandprompt.com>)
Re: planning issue  (Alban Hertroys <alban@magproductions.nl>)
List pgsql-general
if you have time, could you offer advice on this:

i'm doing a database cleanup right now -- 1.4M records -- and each
query is taking 1 second

i can't really wait 2 weeks for this to finish , so I'm hoping that
someone will be able to help out

the issue is that the planner keeps doing a sequential scan, despite
the fact that the requesite columns are indexed.

hoping someone may be able to offer advice:.

SELECT
    *
FROM
    table_a
WHERE
    id != 10001
    AND
    (
            (  field_1 ilike '123' )
            OR
            ( field_2 ilike 'abc' )
    )



         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 ?


// Jonathan Vanasco

pgsql-general by date:

Previous
From: "Bruce McAlister"
Date:
Subject: Re: PostgreSQL 8.2.3 VACUUM Timings/Performance
Next
From: "Joshua D. Drake"
Date:
Subject: Re: planning issue