pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Rhhh Lin <ruanlinehan@hotmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: EXPLAIN <query> command just hangs...
Date: Thu, 2 Nov 2017 16:02:28 -0500
Message-ID: <20171102210228.GA2267@telsasoft.com> (raw)
In-Reply-To: <DB6PR1001MB1141C4DADE28C72A27D70D78AE5C0@DB6PR1001MB1141.EURPRD10.PROD.OUTLOOK.COM>
References: <DB6PR1001MB1141C4DADE28C72A27D70D78AE5C0@DB6PR1001MB1141.EURPRD10.PROD.OUTLOOK.COM>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

On Thu, Nov 02, 2017 at 08:51:23PM +0000, Rhhh Lin wrote:
> However, this query will run for days without completing. I suspect it has to do with the timestamp predicate and lack of using an appropriate index access path. This is what I need to verify/establish.

Perhaps the timestamp index is badly fragmented, and perhaps it would help to
reindex/cluster/pg_repack..

> So I try and perform a simple 'EXPLAIN <query>' in order to check what the planner has for the execution of this query.
> And after approx. six hours waiting, nothing has returned. It is still executing, but has not given me back my prompt (I can see the session is still active).My understanding is that the simple EXPLAIN version does not actually execute the query, so I do not understand why this is also performing poorly/hanging/stuck? Any ideas?

Is explain "wait"ing ?  If you do "ps -fu postgres |grep EXPLAIN" does it say
"EXPLAIN waiting" ?

Or, if you "ps uww ThePID" does it show lots of CPU(or RAM) ?

If you do "SELECT * FROM pg_stat_activity WHERE pid=??" (from "ps" or from
SELECT pg_backend_pid() before starting "explain") does it show "active" state
or waiting ?

If it's waiting, you can see what it's waiting ON by looking at pg_locks..
Maybe like: SELECT c.query, * FROM pg_locks a JOIN pg_locks b USING(relation)
JOIN pg_stat_activity c ON b.pid=c.pid WHERE a.pid=?? (from ps)

Justin


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (12+ messages)  latest in thread

Message-ID: <20171102210228.GA2267@telsasoft.com>
Permalink:  ../20171102210228.GA2267@telsasoft.com/
Also on:    postgresql.org/message-id/20171102210228.GA2267@telsasoft.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: pryzby@telsasoft.com, ruanlinehan@hotmail.com
  Subject: Re: EXPLAIN <query> command just hangs...
  In-Reply-To: <20171102210228.GA2267@telsasoft.com>
  References: <DB6PR1001MB1141C4DADE28C72A27D70D78AE5C0@DB6PR1001MB1141.EURPRD10.PROD.OUTLOOK.COM> <20171102210228.GA2267@telsasoft.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