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

Re: PostgreSQL OR performance

From: "Helio Campos Mello de Andrade" <helio(dot)campos(at)gmail(dot)com>
To: Віталій Тимчишин <tivv00(at)gmail(dot)com>
Cc: "Jeff Davis" <pgsql(at)j-davis(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: PostgreSQL OR performance
Date: 2008-11-06 12:26:20
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
For what i see in four OR-plan.txt tou are doing too much "sequencial scan"
. Create some indexes for those tables using the fields that you use an it
may help you.

OBS: If you already have lots of indexes in your tables it may be a good
time for you re-think your strategy because it´s ot working.
  1 - create indexes for the tables with the fields that you will use in the
query if it is your most important query. If you have others querys that are
used please post those here and we can help you to desing a better plan.
  2 - You cold give us the configuration os the hardware and the posgresql
configuration file and we can see what is going on.


On Thu, Nov 6, 2008 at 8:46 AM, Віталій Тимчишин <tivv00(at)gmail(dot)com> wrote:

> My main message is that I can see this in many queries and many times. But
> OK, I can present exact example.
> 2008/11/5 Jeff Davis <pgsql(at)j-davis(dot)com>
>> On Wed, 2008-11-05 at 13:12 +0200, Віталій Тимчишин wrote:
>> > For a long time already I can see very poor OR performance in
>> > postgres.
>> > If one have query like "select something from table where condition1
>> > or condition2" it may take ages to execute while
>> > "select something from table where condition1" and "select something
>> > from table where condition2" are executed very fast and
>> > "select something from table where condition1 and not condition2 union
>> > all select something from table where condition2" gives required
>> > results fast
>> >
>> What version are you using?
> Server version 8.3.3
>> Have you run "VACUUM ANALYZE"?
> I have autovacuum, but for this example I did vacuum analyze of the whole
> DB.
> The real-life query (autogenerated) looks like the next:
> select as pk1, as pk2 ,t0.run_id as f1_run_id,t1.run_id as
> f2_run_id
> from tmpv_unproc_null_production_company_dup_cons_company as t0, (select *
> from where run_id in (select id from where
> name='test')) as t1
> where
> =
> or
> (, in (select, from atom_match inner join
> atoms_string s1 on atom_match.atom1_id =  inner join atoms_string s2
> on atom_match.atom2_id = where s1.atom_type_id = -1 and
> match_function_id = 2)
> with tmpv_unproc_null_production_company_dup_cons_company:
> create temporary view tmpv_unproc_null_production_company_dup_cons_company
> as select * from where 1=1 and status='unprocessed' and
> run_id in (select id from where name='test')
>> Next, do:
>> EXPLAIN ANALYZE select something from table where condition1 or
>> condition2;
> without analyze is in OR-plan.txt
> Also plans for only condition1, only condition2 and union is attached
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:

Helio Campos Mello de Andrade

In response to


pgsql-performance by date

Next:From: David ReesDate: 2008-11-06 15:47:27
Subject: Re: Occasional Slow Commit
Previous:From: Guillaume CottenceauDate: 2008-11-06 11:57:09
Subject: Re: server space increasing very fast but transaction are very low

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