Re: Limit Heap Fetches / Rows Removed by Filter in Index Scans - Mailing list pgsql-general

From Francisco Olarte
Subject Re: Limit Heap Fetches / Rows Removed by Filter in Index Scans
Date
Msg-id CA+bJJbzUsuc38Gn4=b-t+euWbKZ+ZQMvOm-QVmn_rrrN-0bHyQ@mail.gmail.com
Whole thread Raw
In response to Re: Limit Heap Fetches / Rows Removed by Filter in Index Scans  (Victor Blomqvist <vb@viblo.se>)
List pgsql-general
Victor:

On Fri, Aug 19, 2016 at 8:01 PM, Victor Blomqvist <vb@viblo.se> wrote:

> Thanks! A sub select seems to do it.

I suspected it would be needed, that's why I sugested it.

I prefer to write the queries as CTEs because they are much easier to
read, but IIRC they are some kind of 'optimization fences'. Some times
I end up using psql macros to write queries in CTE-like order in my
scripts and compose them into sub selects when I have this problems.

> Checking these two queries I can see that the first one visits the
> max 50 rows its allowed to and returns 5 rows, while the second one
> finish off after 13 rows fetched and returns the full 10 rows.

Good. The only problem is you are not guaranteed a result, like in the
contrived example I gave, but if it is what you want this is a way to
go.

Francisco Olarte.


pgsql-general by date:

Previous
From: Sameer Kumar
Date:
Subject: Re: PG vs ElasticSearch for Logs
Next
From: Bruno Wolff III
Date:
Subject: endash not a graphic character?