Re: Execution plan does not use index - Mailing list pgsql-general

From Michael Lewis
Subject Re: Execution plan does not use index
Date
Msg-id CAHOFxGoxE_rEOMRzFvm9RyO5yOx+y5CT3Rn+OWqwWKTB=RWT7g@mail.gmail.com
Whole thread Raw
In response to Re: Execution plan does not use index  (Peter Coppens <peter.coppens@datylon.com>)
Responses Re: Execution plan does not use index
List pgsql-general
On Tue, Nov 10, 2020, 3:24 PM Peter Coppens <peter.coppens@datylon.com> wrote:
Index is not used for the subquery

explain 
select mv_inner.*
  from measurement_value AS mv_inner
  where mv_inner.timestamp > '2020-11-06'::timestamp - interval '1 day' and mv_inner.timestamp < '2020-11-07'::timestamp + interval '1 day'
offset 0

==>

Seq Scan on measurement_value mv_inner (cost=0.00..7175777.00 rows=1219616 width=1006)
  Filter: (("timestamp" > '2020-11-05 00:00:00'::timestamp without time zone) AND ("timestamp" < '2020-11-08 00:00:00'::timestamp without time zone))


Curious, how accurate is that row count of 1.2 million records for 3 days? How many total records in the table? If you disable sequential scan, does it choose the index and what cost does it show?

pgsql-general by date:

Previous
From: Peter Coppens
Date:
Subject: Re: Execution plan does not use index
Next
From: Peter Coppens
Date:
Subject: Re: Execution plan does not use index