pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Oleg Lebedev <oleg.lebedev@waterford.org>
To: scott.marlowe <scott.marlowe@ihs.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: TPC-R benchmarks
Date: Wed, 1 Oct 2003 15:23:12 -0700
Message-ID: <200310011523.12895.josh@agliodbs.com> (raw)
In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org>
References: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org>

Oleg,

> All right, my query just finished running with EXPLAIN ANALYZE.
> I show the plan below and also attached it as a file.
> Any ideas?

Yes.  Your problem appears to be right here:

>                                        ->  Nested Loop
> (cost=0.00..54596.00 rows=3 width=88) (actual time=482.41..6630601.46
> rows=348760 loops=1)
>                                              Join Filter:
> ("inner".s_suppkey = "outer".l_suppkey)
>                                              ->  Nested Loop
> (cost=0.00..54586.18 rows=3 width=80) (actual time=383.87..6594984.40
> rows=348760 loops=1)
>                                                    ->  Nested Loop
> (cost=0.00..54575.47 rows=4 width=68) (actual time=199.95..3580882.07
> rows=348760 loops=1)
>                                                          Join Filter:
> ("outer".p_partkey = "inner".ps_partkey)
>                                                          ->  Nested Loop
> (cost=0.00..22753.33 rows=9343 width=49) (actual time=146.85..3541433.10
> rows=348760 loops=1)

For some reason, the row estimate on the supplier --> lineitem join is bad, as 
is the estimate on part --> partsupp.    Let me first check two things:

1) You have an index on l_suppkey and on ps_partkey.
2) you have run ANALYZE on your whole database before the query

If both of those are true, I'd like to see the lines in pg_stats that apply to 
ps_partkey and l_suppkey; please do a:

SELECT * FROM pg_stats WHERE attname = 'l_suppkey' or attname = 'ps_partkey'


-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




view thread (43+ messages)  latest in thread

Message-ID: <200310011523.12895.josh@agliodbs.com>
Permalink:  ../200310011523.12895.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200310011523.12895.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com, oleg.lebedev@waterford.org, scott.marlowe@ihs.com
  Subject: Re: TPC-R benchmarks
  In-Reply-To: <200310011523.12895.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox