Re: Why my query not using index to sort? - Mailing list pgsql-general

From Tom Lane
Subject Re: Why my query not using index to sort?
Date
Msg-id 20311.1538141875@sss.pgh.pa.us
Whole thread Raw
In response to Why my query not using index to sort?  (Arup Rakshit <ar@zeit.io>)
Responses Re: Why my query not using index to sort?  (Arup Rakshit <ar@zeit.io>)
Re: Why my query not using index to sort?  (Arup Rakshit <ar@zeit.io>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Ron
Date:
Subject: Re: How to maintain the csv log files in pg_log directory only forpast 30 days
Next
From: Arup Rakshit
Date:
Subject: Re: Why my query not using index to sort?