Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 7F8E563310F for ; Wed, 25 Mar 2009 00:06:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 04942-09 for ; Wed, 25 Mar 2009 00:05:57 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by mail.postgresql.org (Postfix) with ESMTP id 0FD1A635561 for ; Wed, 25 Mar 2009 00:04:26 -0300 (ADT) Received: by ey-out-2122.google.com with SMTP id 22so432376eye.61 for ; Tue, 24 Mar 2009 20:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :received:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=5D7dxSpGhAFr+5ek7z0C98H/ISHrn+BjadflXXQBUbM=; b=X/N7VFSyHC6VXw3g+hoDXpNuYOK0go6W64NFu3yXD+2+PIBlyS4x9VCmr0GBUQEGCr dRjlOZhpy9fsrXVDY7XKAOInzGLvjd5wcONN7ZjLmnSDnoVO7q51lERr/+c1rBRnbeYx rpV5ZN9TwpKZpNksbXDqwpHSl3eB8tJqyG4Co= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=YcMq07yx1tIWUJX19cxa9obfezBg4zN89wsHojGawxKNDCRNAJAWNadDlu8xylAJn7 mckfiT3nl8sX5DohFMp4OFgqnVEqtIL8PjFLrs1Kd0ncVCb+gnXRTIzxPbZJm48bEEOA A9ezMIJ81wGThDKOuybjIgMZom+ScYm9QGSWc= MIME-Version: 1.0 In-Reply-To: <7fd310d10903241521v1cbf5d7aueca653e03ed98649@mail.gmail.com> References: <7fd310d10903231203r1bd37b8cn8baeadae83253f44@mail.gmail.com> <7fd310d10903241521v1cbf5d7aueca653e03ed98649@mail.gmail.com> Date: Wed, 25 Mar 2009 04:04:08 +0100 Received: by 10.211.180.15 with SMTP id h15mr3745926ebp.25.1237950264895; Tue, 24 Mar 2009 20:04:24 -0700 (PDT) Message-ID: Subject: Re: Help Me Understand Why I'm Getting a Bad Query Plan From: marcin mank To: Bryan Murphy Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/359 X-Sequence-Number: 33281 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!)? Greetings Marcin