EXPLAIN <query> command just hangs...

From: Rhhh Lin <ruanlinehan(at)hotmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: EXPLAIN <query> command just hangs...
Date: 2017-11-02 20:51:23
Message-ID: DB6PR1001MB1141C4DADE28C72A27D70D78AE5C0@DB6PR1001MB1141.EURPRD10.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,
version = Postgres 9.3.10

I have a table with approx. 5 million rows. It is defined something like the below.

col: type:
timestamp bigint
measurement_id integer
value numeric(24,5)
minval numeric(24,5)
maxval numeric(24,5)

There are two BTree indexes in place on the PK ("timestamp", "measurement_id") and on ("measurement_id").

Problem:
I have an aggregate query along the lines of....

select count(*) as CNT, sum(value) as SUMVALUE, min(value) as MINVALUE, max(value) as MAXVALUE, timestamp
from my_table_name
where timestamp BETWEEN 1506676560000 AND 1508750220000
AND measurement_id IN (12345, 6789)
GROUP BY timestamp;

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.

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?

*Also, as a sidenote - can someone please expand on why one (I was not involved in the creation of this DB/schema definition) would choose to have the definition of the timestamp column as a bigint in this case?

Kind regards,
Ruan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Pryzby 2017-11-02 21:02:28 Re: EXPLAIN <query> command just hangs...
Previous Message nmmulla 2017-11-02 20:07:46 Re: syntax error