Re: Why my query not using index to sort?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Arup Rakshit <ar(at)zeit(dot)io>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why my query not using index to sort?
Date: 2018-09-28 13:37:55
Message-ID: 20311.1538141875@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Arup Rakshit <ar(at)zeit(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arup Rakshit 2018-09-28 14:49:12 Re: Why my query not using index to sort?
Previous Message Ron 2018-09-28 13:31:46 Re: How to maintain the csv log files in pg_log directory only for past 30 days