Re: Query only slow on first run - Mailing list pgsql-performance

From Tom Lane
Subject Re: Query only slow on first run
Date
Msg-id 2224.1196269972@sss.pgh.pa.us
Whole thread Raw
In response to Re: Query only slow on first run  ("Dave Dutcher" <dave@tridecap.com>)
List pgsql-performance
"Dave Dutcher" <dave@tridecap.com> writes:
> ... According to the explain analyze
> there are only 646 rows in posts which match your criteria, so it does seem
> like scanning posts first might be the right thing to do.

No, that's not right.  What the output actually shows is that only 646
posts rows were needed to produce the first 200 aggregate rows, which was
enough to satisfy the LIMIT.  The planner is evidently doing things this
way in order to exploit the presence of the LIMIT --- if it had to
compute all the aggregate results it would likely have picked a
different plan.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Usama Munir Dar"
Date:
Subject: Re: Training Recommendations
Next
From: Simon Riggs
Date:
Subject: Re: TB-sized databases