Re: Why does row estimation on nested loop make no sense to me

From: Jeff Amiel <becauseimjeff(at)yahoo(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why does row estimation on nested loop make no sense to me
Date: 2013-05-17 18:31:16
Message-ID: 1368815476.14515.YahooMailNeo@web161404.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> explain analyze
> select  era.child_entity  from entity_rel era  join user_entity ue on ue.entity_id = era.parent_entity and ue.user_id=12345
>
> Nested Loop  (cost=0.00..2903.37 rows=29107 width=4) (actual time=0.028..0.274 rows=201 loops=1)
>  ->  Index Only Scan using entity_pk on user_entity ue  (cost=0.00..62.68 rows=2 width=4) (actual time=0.011..0.012 rows=1 loops=1)
>        Index Cond: (user_id = 12345)
>        Heap Fetches: 1
>  ->  Index Scan using rel_parent on entity_rel era  (cost=0.00..1261.85 rows=317 width=8) (actual time=0.013..0.164 rows=201 loops=1)
>        Index Cond: (parent_entity = ue.entity_id)
> Total runtime: 0.361 ms

>Have you tried analyze (it's probably a case of insufficient/outdated
>statistics to planner's disposal) or probably consider changing
>default_statistics_target?

Again - my question revolves not around the whether or not I am getting good or bad estimates - my question is related to the fact that the nested-loop row estimation does not appear to be derived from the nodes below it - it is off by orders of magnitude.  I've never seen this before.
That aside, yes - I did analyze and tweak stats target during experimentation - no change.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alfonso Afonso 2013-05-17 19:21:35 Re: Best practice on inherited tables
Previous Message Amit Langote 2013-05-17 17:20:52 Re: Why does row estimation on nested loop make no sense to me