From: Dimitrios Apostolou <jimis@gmx.net>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: SELECT * FROM huge_table LIMIT 10; Why does it take more than 10 min to complete, with cold caches
Date: Wed, 1 Feb 2023 19:15:19 +0100 (CET)
Message-ID: <843f9f52-604b-246c-024e-c730b366203b@gmx.net> (raw)
In-Reply-To: <CAKFQuwaUy=P_pNGNgcoyFcNExrRSqwhVTUE-SfUrGbj08BzLRw@mail.gmail.com>
References: <b847d458-5a03-718e-5467-422fc0e51004@gmx.net>
<1079393.1675178901@sss.pgh.pa.us>
<CAKFQuwaUy=P_pNGNgcoyFcNExrRSqwhVTUE-SfUrGbj08BzLRw@mail.gmail.com>
On Tue, 31 Jan 2023, David G. Johnston wrote:
>
> It feels like there is room for improvement here using table statistics and the visibility map to significantly reduce the number of pages retrieved that turn out to be all dead.
Yes, I too wish postgres was more clever for a simple unordered query. I
should also mention that this table has two btree indices, one primary key
index and one on another column. Would it be feasible to "descend" an
index in order to immediately find some live data?
> A limit without an order is not a query to optimize for of course...
A good reason is that the web interface I'm using to browse my tables (and
I guess many other too) do a simple limited+unordered SELECT when you
click on a table. Timing out was what made me look deeper. I couldn't
accept that no matter how slow my system is, it has trouble returning a
few rows.
It is also the first query somoebody will type on psql to interactively
get a clue about the contents of a table.
Regards,
Dimitris
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: jimis@gmx.net, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: SELECT * FROM huge_table LIMIT 10; Why does it take more than 10 min to complete, with cold caches
In-Reply-To: <843f9f52-604b-246c-024e-c730b366203b@gmx.net>
References: <b847d458-5a03-718e-5467-422fc0e51004@gmx.net> <1079393.1675178901@sss.pgh.pa.us> <CAKFQuwaUy=P_pNGNgcoyFcNExrRSqwhVTUE-SfUrGbj08BzLRw@mail.gmail.com> <843f9f52-604b-246c-024e-c730b366203b@gmx.net>
* 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