Skip site navigation (1) Skip section navigation (2)

Index called with Union but not with OR clause

From: "V Chitra" <vchitra(at)techbooks(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Index called with Union but not with OR clause
Date: 2004-02-20 06:56:22
Message-ID: 008401c3f77e$a78f1d20$18dda8c0@VICHITRA (view raw, whole thread or download thread mbox)
Lists: pgsql-adminpgsql-performance
Hi All,

I have a select statement 

select * from v_func_actual_costs
where parent_project='10478' or proj_pk = '10478'

both the fields parent_project and proj_pk have indexes based on them, but when I ran explain plan on this statement I found that none of the indexes are being called. But, if I make two separate statement and combine them with Union ALL, the indexes are being called. The select statement in this case is

select * from ct_admin.v_func_actual_costs
where parent_project='10478'
union all
select * from ct_admin.v_func_actual_costs
where proj_pk = '10478' 

Can anybody help me to find a reason for the same. This is just a part of the query so I cannot use the Union ALL clause.

Thanks in advance



pgsql-performance by date

Next:From: vathakarDate: 2004-02-20 09:16:15
Subject: Slow in morning hours
Previous:From: Josh BerkusDate: 2004-02-19 21:17:35
Subject: Re: Forcing filter/join order?

pgsql-admin by date

Next:From: Matt ClarkDate: 2004-02-20 10:12:37
Subject: Re: "DELETE FROM" protection
Previous:From: Jeremy SmithDate: 2004-02-20 06:05:33
Subject: "DELETE FROM" protection

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group