From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Kane <tim.kane@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: Avoiding out of date statistics / planner
Date: Wed, 12 Feb 2020 10:15:59 -0500
Message-ID: <23751.1581520559@sss.pgh.pa.us> (raw)
In-Reply-To: <CADVWZZ+Nwc1v6pksbgEYmY8H+hOGY70y3LUEVAC8MHTvJ9Le6w@mail.gmail.com>
References: <CADVWZZ+Nwc1v6pksbgEYmY8H+hOGY70y3LUEVAC8MHTvJ9Le6w@mail.gmail.com>
Tim Kane <tim.kane@gmail.com> writes:
> Every now and again, I will encounter an unexplained long-running query.
> It’s a head scratcher moment, because this query that is still running for
> 20 minutes (not blocking) can be run independently in about 500ms
Without some kind of context (like, have you been doing something to
the table(s) involved that would drastically change their statistics)
it's hard to comment on this. It's not obvious from the info
provided that this is a bad-plan issue rather than something else.
> On the application side, we can explicitly issue a VACUUM ANALYZE after
> each bulk operation - and often that is precisely what happens..
> But - I am keenly aware that this cannot be performed within a transaction.
Plain ANALYZE can be, and that's all you need if the problem is to
update stats.
regards, tom lane
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: tgl@sss.pgh.pa.us, tim.kane@gmail.com
Subject: Re: Avoiding out of date statistics / planner
In-Reply-To: <23751.1581520559@sss.pgh.pa.us>
References: <CADVWZZ+Nwc1v6pksbgEYmY8H+hOGY70y3LUEVAC8MHTvJ9Le6w@mail.gmail.com> <23751.1581520559@sss.pgh.pa.us>
* 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