Re: Postgres not using index on views - Mailing list pgsql-performance

From Tom Lane
Subject Re: Postgres not using index on views
Date
Msg-id 26256.1586236149@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postgres not using index on views  (Justin Pryzby <pryzby@telsasoft.com>)
Responses RE: Postgres not using index on views
List pgsql-performance
Justin Pryzby <pryzby@telsasoft.com> writes:
> On Mon, Apr 06, 2020 at 02:19:59PM +0000, Rick Vincent wrote:
>> The following query takes an extremely long time for only 180 rows, and what this means is that we would have to
indexanything appearing in the where clause for every table in order to use views because the views seem not to
considerthe select clause.  Why is that and does anyone know a way around this? 

> Is there a reason why you don't store the extracted value in its own column ?

The planner seems to be quite well aware that the slower query is going to
be slower, since the estimated costs are much higher.  Since it's not
choosing to optimize into a faster form, I wonder whether it's constrained
by semantic requirements.  In particular, I'm suspicious that some of
those functions you have in the view are marked "volatile", preventing
them from being optimized away.

Beyond that guess, though, there's really not enough info here to say.
The info we usually ask for to debug slow-query problems is explained
at

https://wiki.postgresql.org/wiki/Slow_Query_Questions

            regards, tom lane



pgsql-performance by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Postgres not using index on views
Next
From: Laurenz Albe
Date:
Subject: Re: Postgres not using index on views