From: Tom Lane <tgl@sss.pgh.pa.us>
To: Arup Rakshit <ar@zeit.io>
Cc: pgsql-general@postgresql.org
Subject: Re: Why my query not using index to sort?
Date: Fri, 28 Sep 2018 09:37:55 -0400
Message-ID: <20311.1538141875@sss.pgh.pa.us> (raw)
In-Reply-To: <D973243A-5DDC-4B20-A1DF-A0C14A487D2A@zeit.io>
References: <D973243A-5DDC-4B20-A1DF-A0C14A487D2A@zeit.io>
Arup Rakshit <ar@zeit.io> writes:
> My query is not using name index to sort the result.
Given the rowcounts here, I think the planner is making the right choice.
Sorting 70-some rows with a Sort node is probably cheaper than doing
random disk I/O to get them in sorted order. With more rows involved,
it might make the other choice.
As a testing measure (don't do it in production!), you could set
enable_sort = off, which will force the planner to pick a non-Sort
plan if possible. Then you could see whether that's actually faster
or slower, and by how much.
regards, tom lane
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: tgl@sss.pgh.pa.us, ar@zeit.io
Subject: Re: Why my query not using index to sort?
In-Reply-To: <20311.1538141875@sss.pgh.pa.us>
References: <D973243A-5DDC-4B20-A1DF-A0C14A487D2A@zeit.io> <20311.1538141875@sss.pgh.pa.us>
* 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