Re: BUG #14302: SQL with LIMIT degrades performance seriously

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Kaijiang Chen <chenkaijiang(at)gmail(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14302: SQL with LIMIT degrades performance seriously
Date: 2016-08-31 13:55:30
Message-ID: CA+bJJbyuQ2t4Q_2iaGuY9QvLnB+vDJ8C9LV7T01kASPA28jbsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Aug 31, 2016 at 6:09 AM, Kaijiang Chen <chenkaijiang(at)gmail(dot)com> wrote:
> In the sql "select * from renren.user_relations where parent_id=846346 order
> by user_id LIMIT 10;", planner can query the number of rows (with
> parent_id=846346) from the btree index, right?
> If so, planner will know that it's better to sort the rows (actually less
> than 2000) than to scan 10M rows.

mmmm, AFAIK planner does NOT query, it plans using stored statistics.
This is why some data distribution, which are a bad match for the
postgres ways of storing stats, tend to plan ( oacasionally ) badly.

Francisco Olarte.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Francisco Olarte 2016-08-31 13:58:58 Re: BUG #14302: SQL with LIMIT degrades performance seriously
Previous Message Kaijiang Chen 2016-08-31 12:42:06 Re: BUG #14302: SQL with LIMIT degrades performance seriously