From: | twoflower <standa(dot)kurik(at)gmail(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Query > 1000× slowdown after adding datetime comparison |
Date: | 2015-08-31 16:09:11 |
Message-ID: | 1441037351126-5864045.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
I have the following three tables:
DOCUMENT
id (index)
documenttype
date_last_updated: timestamp(6) (indexed)
EXTERNAL_TRANSLATION_UNIT
id (indexed)
fk_id_document (indexed)
EXTERNAL_TRANSLATION
id (indexed)
fk_id_translation_unit (indexed)
Table sizes:
DOCUMENT: 381 000
EXTERNAL_TRANSLATION_UNIT: 76 000 000
EXTERNAL_TRANSLATION: 76 000 000
Now the following query takes about 36 minutes to finish:
SELECT u.id AS id_external_translation_unit,
r.id AS id_external_translation,
u.fk_id_language AS fk_id_source_language,
r.fk_id_language AS fk_id_target_language,
doc.fk_id_job
FROM "EXTERNAL_TRANSLATION_UNIT" u
JOIN "DOCUMENT" doc ON u.fk_id_document = doc.id
JOIN "EXTERNAL_TRANSLATION" r ON u.id = r.fk_id_translation_unit
WHERE doc.date_last_updated >= date(now() - '171:00:00'::interval)
ORDER BY r.id LIMIT 1000
This is the query plan:
<http://postgresql.nabble.com/file/n5864045/qp1.png>
If I remove the WHERE condition, it returns immediately.
Am I doing something obviously wrong?
Thank you for any ideas.
--
View this message in context: http://postgresql.nabble.com/Query-1000-slowdown-after-adding-datetime-comparison-tp5864045.html
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2015-08-31 16:19:35 | Re: Query > 1000× slowdown after adding datetime comparison |
Previous Message | Tom Lane | 2015-08-31 14:36:01 | Re: is there any way we can push join predicate into inner table |