pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Coppens <peter.coppens@datylon.com>
To: Michael Lewis <mlewis@entrata.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Execution plan does not use index
Date: Wed, 11 Nov 2020 15:30:37 +0100
Message-ID: <96DF1F02-C91B-4960-87C4-4E3BA2EC594A@datylon.com> (raw)
In-Reply-To: <CAHOFxGp=mbDDEwvtLZLidogd_O_G9+tU3DBTdXfghuunaRgJHw@mail.gmail.com>
References: <CAEkf4WBnCDcqQXfw4z-TpTYucBE=AEHEQjLd3QvOtMrPrrK6fA@mail.gmail.com>
	<CAHOFxGrR-pOGQEiZdYzTB7EwoeW_3PsP0pxT0RfG3GQV9gPQCg@mail.gmail.com>
	<D797FCC9-FBCD-4206-BCB5-50A2F31C94E6@datylon.com>
	<CAFj8pRB6cxB2KRugFZDFg=ZX7VLpwQouF3C=wPhgv4=ZWaEwgw@mail.gmail.com>
	<1C729C96-97BB-46CF-9457-876DCC395923@datylon.com>
	<64AAA8DD-FD2F-4DFC-BDA4-109C024609B1@datylon.com>
	<CAHOFxGqJE1BsTOqS2sbs6k7Lw--atw0Xufio263xHWzfa_tT=g@mail.gmail.com>
	<70D29A79-C968-4310-B4D7-3203A739F261@datylon.com>
	<CAHOFxGoxE_rEOMRzFvm9RyO5yOx+y5CT3Rn+OWqwWKTB=RWT7g@mail.gmail.com>
	<F3CEF98E-71A4-473D-A1CA-4ACA889B43FA@datylon.com>
	<CAHOFxGp=mbDDEwvtLZLidogd_O_G9+tU3DBTdXfghuunaRgJHw@mail.gmail.com>

> 
> Ahhh. You don't have a single column index on the timestamp value or a multi column one with timestamp first. No wonder the subquery didn't help. My apologies for not realizing that before. Thanks for satisfying my curiosity why it didn't perform like it should. Certainly, that index may or may not be worth creating and maintaining.
Indeed. Typical queries use both device id and a timestamp range. Only in some queries more than a few devices are needed.

> 
> Obviously the 3 days worth of data is also too high (just quick and safe). Depending on what your server timezone vs the the most divergent timezone on a device, that could be tightened up. Regardless. If the 5 seconds runtime you got to with the correlated subquery on the where clause is sufficient, then no need to continue I suppose.
Yeah, I am ok with the performance now. The overall query  where this was extracted from (and which had multiple full table scans) went from more than 2 hours to 30 seconds. Given it’s a daily ‘async’  report that is sufficient.

> 
> It seems odd to me to not do any basic adjustment of random_page_cost though. It isn't a magic number that the core team know to be perfect. It is a baseline that is likely to be quite different for each use case and server config. While there are no hard and fast rules and absolute right answers, it seems prudent to at least follow the advice of the community and lower it a ways if storage is ssd style and/or cache hits are quite high.
Ic. Well I don’t mine experimenting with it, and will certainly remember it next time. I guess I was demotivated because I read lot’s of warnings but these might have been about disabling sequential scans and not about page cost settings.






view thread (14+ messages)  latest in thread

Message-ID: <96DF1F02-C91B-4960-87C4-4E3BA2EC594A@datylon.com>
Permalink:  ../96DF1F02-C91B-4960-87C4-4E3BA2EC594A@datylon.com/
Also on:    postgresql.org/message-id/96DF1F02-C91B-4960-87C4-4E3BA2EC594A@datylon.com

 · 

reply

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.coppens@datylon.com, mlewis@entrata.com, pavel.stehule@gmail.com
  Subject: Re: Execution plan does not use index
  In-Reply-To: <96DF1F02-C91B-4960-87C4-4E3BA2EC594A@datylon.com>
  References: <CAEkf4WBnCDcqQXfw4z-TpTYucBE=AEHEQjLd3QvOtMrPrrK6fA@mail.gmail.com> <CAHOFxGrR-pOGQEiZdYzTB7EwoeW_3PsP0pxT0RfG3GQV9gPQCg@mail.gmail.com> <D797FCC9-FBCD-4206-BCB5-50A2F31C94E6@datylon.com> <CAFj8pRB6cxB2KRugFZDFg=ZX7VLpwQouF3C=wPhgv4=ZWaEwgw@mail.gmail.com> <1C729C96-97BB-46CF-9457-876DCC395923@datylon.com> <64AAA8DD-FD2F-4DFC-BDA4-109C024609B1@datylon.com> <CAHOFxGqJE1BsTOqS2sbs6k7Lw--atw0Xufio263xHWzfa_tT=g@mail.gmail.com> <70D29A79-C968-4310-B4D7-3203A739F261@datylon.com> <CAHOFxGoxE_rEOMRzFvm9RyO5yOx+y5CT3Rn+OWqwWKTB=RWT7g@mail.gmail.com> <F3CEF98E-71A4-473D-A1CA-4ACA889B43FA@datylon.com> <CAHOFxGp=mbDDEwvtLZLidogd_O_G9+tU3DBTdXfghuunaRgJHw@mail.gmail.com> <96DF1F02-C91B-4960-87C4-4E3BA2EC594A@datylon.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