Re: how does the planer to estimate row when i use order by and group by

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: 楊新波 <silent0608(at)gmail(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: how does the planer to estimate row when i use order by and group by
Date: 2014-08-12 12:47:05
Message-ID: CABRT9RBdQvdXjhY5qKEAkXvRqT+zBBazehqnV9hoAaOtDpYHDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Aug 12, 2014 at 5:59 AM, 楊新波 <silent0608(at)gmail(dot)com> wrote:
> why does the planer estimate 200 rows when i use order by and group by .
> evn:postgresql 8.4 and 9.3

> Can anybody suggest something or explain this behavior?

Because the table is empty, analyze doesn't store any stats for the
table, so the planner uses some default guesses.

This is actually beneficial for cases where you have done some inserts
to a new table, and autovacuum hasn't gotten around to analyzing it
yet. And it rarely hurts because any query plan will be fast when
there's no data.

Regards,
Marti

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2014-08-14 18:18:29 Re: 60 core performance with 9.3
Previous Message Mark Kirkwood 2014-08-12 04:56:10 Re: 60 core performance with 9.3