From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Corey Taylor <corey.taylor.fl@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to see index was rejected for seq scan?
Date: Sat, 16 Dec 2017 09:25:07 -0500
Message-ID: <49e61761-9b33-436e-0568-807f5cf06146@2ndquadrant.com> (raw)
In-Reply-To: <CADBz386iXZ=Jgs_N-3u4G7UtCt3A-x3EMFzKJ1DE-j-d8NGz+g@mail.gmail.com>
References: <CADBz386iXZ=Jgs_N-3u4G7UtCt3A-x3EMFzKJ1DE-j-d8NGz+g@mail.gmail.com>
On 12/16/17 04:03, Corey Taylor wrote:
> Essentially, if an index was deemed not to save cost during the input
> scan, the planner will schedule a seq scan. What I'm wondering if there
> is anything that indicates a valid index for the scan was found and
> rejected (reason doesn't necessarily matter). I couldn't find anything
> in the using explain document, but I have probably missed it. I would
> assume the index would be used to determine if the filter requires a
> large scan count.
This isn't really possible in the general case, because the planner
doesn't actually materialize all possible plans for complex queries,
which would be very expensive.
But for simple queries, you might get some insight if you set
enable_seqscan to off. Then the planner will give you an index-using
plan if it is at all possible. Then you can compare the costs. If the
planner still gives you a sequential scan, then the index was not
applicable for other reasons.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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: peter.eisentraut@2ndquadrant.com, corey.taylor.fl@gmail.com
Subject: Re: How to see index was rejected for seq scan?
In-Reply-To: <49e61761-9b33-436e-0568-807f5cf06146@2ndquadrant.com>
References: <CADBz386iXZ=Jgs_N-3u4G7UtCt3A-x3EMFzKJ1DE-j-d8NGz+g@mail.gmail.com> <49e61761-9b33-436e-0568-807f5cf06146@2ndquadrant.com>
* 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