Re: [PERFORM] PSQL 8.4 - partittions - join tables - not optimal plan

2009-09-10 Thread A. Kretschmer
In response to Vratislav Benes : > but when I try make a condition by join table, the query plan is not optimal: > > > select period_id from periods where y=2009 and w=14; > period_id > --- >704 > (1 row) > > > explain select sum(s_pcs),sum(s_val) > from data d inner join perio

Re: [PERFORM] Forcing postgresql to use an index

2009-09-10 Thread Eugene Morozov
Grzegorz Jaƛkiewicz writes: > Learn it to not generate with "WITH IN (subq)", is this can be quite > slow on postgresql. Use joins instead. OK, I've split the query in two (can't make Django to generate JOIN in this case) and it always uses index now. This immediately opened road for other optim

[PERFORM] PSQL 8.4 - partittions - join tables - not optimal plan

2009-09-10 Thread Vratislav Benes
Hello, could you help me with joined query from partitioned table, please? I have a table "data" with partitions by period_id CREATE TABLE data ( period_id smallint NOT NULL DEFAULT 0, store_id smallint NOT NULL DEFAULT 0, product_id integer NOT NULL DEFAULT 0, s_pcs real NOT NULL DEFAULT

Re: [PERFORM] slow query : very simple delete, 100% cpu, nearly no disk activity

2009-09-10 Thread Vincent de Phily
On Monday 07 September 2009 03:25:23 Tom Lane wrote: > Vincent de Phily writes: > > I've been running this simple delete since yesterday afternoon : > >> db=# explain delete from message where datetime < '2009-03-03'; > >> Seq Scan on message (cost=0.00..34131.95 rows=133158 width=6) > >> Filter:

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
On Thu, Sep 10, 2009 at 10:56 AM, Tom Lane wrote: > bricklen writes: > > I just created a new index as Tom said, and the query *does* use the new > > index (where ofid precedes date in the definition). > > And is it indeed faster than the other alternatives? > >regards, t

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread Tom Lane
bricklen writes: > I just created a new index as Tom said, and the query *does* use the new > index (where ofid precedes date in the definition). And is it indeed faster than the other alternatives? regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-per

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
On Thu, Sep 10, 2009 at 10:07 AM, bricklen wrote: > On Thu, Sep 10, 2009 at 10:02 AM, Robert Haas wrote: > >> On Thu, Sep 10, 2009 at 12:56 PM, bricklen wrote: >> > On Thu, Sep 10, 2009 at 8:43 AM, Tom Lane wrote: >> >> >> >> bricklen writes: >> >> > Is there any other data I can provide to sh

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
On Thu, Sep 10, 2009 at 10:02 AM, Robert Haas wrote: > On Thu, Sep 10, 2009 at 12:56 PM, bricklen wrote: > > On Thu, Sep 10, 2009 at 8:43 AM, Tom Lane wrote: > >> > >> bricklen writes: > >> > Is there any other data I can provide to shed some light on this? > >> > >> The table and index defini

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread Robert Haas
On Thu, Sep 10, 2009 at 12:56 PM, bricklen wrote: > On Thu, Sep 10, 2009 at 8:43 AM, Tom Lane wrote: >> >> bricklen writes: >> > Is there any other data I can provide to shed some light on this? >> >> The table and index definitions? >> >> The straight indexscan would probably win if the index c

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
On Thu, Sep 10, 2009 at 9:57 AM, Robert Haas wrote: > 2009/9/10 : > >> Playing around with seq_page_cost (1) and random_page_cost (1), I can > get > >> the correct index selected. Applying those same settings to our > production > >> server does not produce the optimal plan, though. > > > > I do

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread Robert Haas
2009/9/10 : >> Playing around with seq_page_cost (1) and random_page_cost (1), I can get >> the correct index selected. Applying those same settings to our production >> server does not produce the optimal plan, though. > > I doubt setting seq_page_cost and random_page_cost to the same value is >

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
On Thu, Sep 10, 2009 at 8:43 AM, Tom Lane wrote: > bricklen writes: > > Is there any other data I can provide to shed some light on this? > > The table and index definitions? > > The straight indexscan would probably win if the index column order > were ofid, date instead of date, ofid. I can't

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread Tom Lane
bricklen writes: > Is there any other data I can provide to shed some light on this? The table and index definitions? The straight indexscan would probably win if the index column order were ofid, date instead of date, ofid. I can't tell if you have any other queries for which the existing colu

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread tv
> Playing around with seq_page_cost (1) and random_page_cost (1), I can get > the correct index selected. Applying those same settings to our production > server does not produce the optimal plan, though. I doubt setting seq_page_cost and random_page_cost to the same value is reasonable - random a

Re: [PERFORM] Best Profiler for PostgreSQL

2009-09-10 Thread Robert Haas
On Wed, Sep 9, 2009 at 6:15 AM, Reydan Cankur wrote: > Hi, > > I am running PostgreSQL-8.4.0 on a SMP Server which has 32 processors > (32X2=64 cores). I am working on database parallelism and I need to do > profiling in order to find the relevant parts to parallelize. I wrote 15 > queries which a

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
Hi Tomas, 2009/9/10 > > default_statistics_target = 100 (tried with 500, no change). Vacuum > > analyzed > > before initial query, and after each change to default_statistics_target. > > Modifying the statistics target is useful only if the estimates are > seriously off, which is not your case -

Re: [PERFORM] Sub-optimal plan chosen

2009-09-10 Thread tv
> default_statistics_target = 100 (tried with 500, no change). Vacuum > analyzed > before initial query, and after each change to default_statistics_target. Modifying the statistics target is useful only if the estimates are seriously off, which is not your case - so it won't help, at least not re

[PERFORM] Sub-optimal plan chosen

2009-09-10 Thread bricklen
In the following query, We are seeing a sub-optimal plan being chosen. The following results are after running the query several times (after each change). dev1=# select version(); version ---