pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bryan Murphy <bmurphy1976@gmail.com>
To: marcin mank <marcin.mank@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Help Me Understand Why I'm Getting a Bad Query Plan
Date: Tue, 24 Mar 2009 22:47:00 -0500
Message-ID: <7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.com> (raw)
In-Reply-To: <b1b9fac60903242004p5fe8b68fwd6f1ada767766b21@mail.gmail.com>
References: <7fd310d10903231203r1bd37b8cn8baeadae83253f44@mail.gmail.com>
	<7fd310d10903241521v1cbf5d7aueca653e03ed98649@mail.gmail.com>
	<b1b9fac60903242004p5fe8b68fwd6f1ada767766b21@mail.gmail.com>

On Tue, Mar 24, 2009 at 10:04 PM, marcin mank <marcin.mank@gmail.com> wrote:
> There is one thing I don`t understand:
>
>              ->  Nested Loop  (cost=0.00..180564.28 rows=1806
> width=37) (actual time=0.192..60.214 rows=3174 loops=1)
>                    ->  Index Scan using visitors_userid_index2 on
> visitors v  (cost=0.00..2580.97 rows=1300 width=33) (actual
> time=0.052..2.342 rows=897 loops=1)
>                          Index Cond: (userid =
> 'fbe2537f21d94f519605612c0bf7c2c5'::bpchar)
>                    ->  Index Scan using
> itemexperiencelog__index__visitorid on itemexperiencelog l
> (cost=0.00..134.04 rows=230 width=70) (actual time=0.013..0.040 rows=4
> loops=897)
>                          Index Cond: (l.visitorid = v.id)
>
> If it expects 1300 visitors with the userid, and for each of them to
> have 230 entries in itemexperiencelog, how can it come up with 1806
> returned rows (and be about right!)?

I'm not sure I follow what you're saying.

One thing to keep in mind, due to a lapse in our judgement at the
time, this itemexperiencelog table serves as both a current state
table, and a log table.  Therefore, it potentially has multiple
redundant entries, but we typically only look at the most recent entry
to figure out the state of the current item.

We're in the process of re-factoring this now, as well as
denormalizing some of the tables to eliminate unnecessary joins, but I
keep running into these problems and need to understand what is going
on so that I know we're fixing the correct things.

Thanks,
Bryan



view thread (14+ messages)  latest in thread

Message-ID: <7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.com>
Permalink:  ../7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.com/
Also on:    postgresql.org/message-id/7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: bmurphy1976@gmail.com, marcin.mank@gmail.com
  Subject: Re: Help Me Understand Why I'm Getting a Bad Query Plan
  In-Reply-To: <7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.com>
  References: <7fd310d10903231203r1bd37b8cn8baeadae83253f44@mail.gmail.com> <7fd310d10903241521v1cbf5d7aueca653e03ed98649@mail.gmail.com> <b1b9fac60903242004p5fe8b68fwd6f1ada767766b21@mail.gmail.com> <7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.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