From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Bob Jones <r.a.n.d.o.m.d.e.v.4+postgres@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: To prefer sorts or filters in postgres, that is the question....
Date: Tue, 17 Apr 2018 10:19:05 +0200
Message-ID: <1523953145.2361.2.camel@cybertec.at> (raw)
In-Reply-To: <CA+HuS5HOBqysd25njHFrs2oP-cag9VEwetDGqX1T95-da1Pw5A@mail.gmail.com>
References: <CA+HuS5EOeuBvsr_jOCjnEMBsJ0j+bWnKoBUKEqozLu8Eg7=MWQ@mail.gmail.com>
<1523946266.2329.5.camel@cybertec.at>
<CA+HuS5HOBqysd25njHFrs2oP-cag9VEwetDGqX1T95-da1Pw5A@mail.gmail.com>
Bob Jones wrote:
> My current thinking is that the filter is a bit like an "fgrep" and
> the sort actually requires memory allocation and some "real work", and
> thus I've settled on the filter for now pending experiments with a
> larger quantity of data.
That's fine.
A top-1-sort is less work than you maybe think:
You go through all items and find the biggest one.
So there is one comparison operator per row - very similar to
what happens when "grepping" for NULL values.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, r.a.n.d.o.m.d.e.v.4+postgres@gmail.com
Subject: Re: To prefer sorts or filters in postgres, that is the question....
In-Reply-To: <1523953145.2361.2.camel@cybertec.at>
References: <CA+HuS5EOeuBvsr_jOCjnEMBsJ0j+bWnKoBUKEqozLu8Eg7=MWQ@mail.gmail.com> <1523946266.2329.5.camel@cybertec.at> <CA+HuS5HOBqysd25njHFrs2oP-cag9VEwetDGqX1T95-da1Pw5A@mail.gmail.com> <1523953145.2361.2.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox