Re: How to see index was rejected for seq scan?

From: Corey Taylor <corey(dot)taylor(dot)fl(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How to see index was rejected for seq scan?
Date: 2017-12-16 21:27:57
Message-ID: CADBz386etzbEwYPx_WCDWHD=acbXSAb+qKFu6v79YhFj0qBJww@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 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.

Thanks! This gives me enough information. I was essentially looking for
something concrete to discuss for cases where someone even more novice than
myself in query optimization points to issues after adding an index.

I have a tangential question that I am curious about more than it being
helpful in building queries.

Is index information used to determine the input scan cost or is that
determine through another mechanism or other metadata in the table? I mean
this for a simple case and not in an exhaustive general sense. For example
a table with an id and timestamp column with an index on the id and
timestamp filtered by a date range.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Venkata B Nagothi 2017-12-17 07:05:26 Re: Can postgresql ignore DST ?
Previous Message Peter Devoy 2017-12-16 19:49:38 Re: User-defined print format for extension-defined types in psql output