From: Dinesh Chandra 12108 <Dinesh.Chandra@cyient.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: FW: Re: Query is running very slow......
Date: Fri, 26 May 2017 12:31:15 +0000
Message-ID: <7716a1169e2249e282a0c8527b2d502f@cyient.com> (raw)
In-Reply-To: <acba2082-c299-e712-4964-29c47f839a57@2ndquadrant.com>
References: <3152be5a435f45649cef6bf9321beb9a@cyient.com>
<4caed7cc-07d8-e364-78ca-7a96b9780a9d@2ndquadrant.com>
<39b30cfde27a48898340a69940581727@cyient.com>
<acba2082-c299-e712-4964-29c47f839a57@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Hi Thomas,
Thanks for your reply.
Yes, the query is absolutely same which I posted.
Please suggest if something need to change in query.
As Per your comment...
The query you posted includes there two join conditions:
evidence_to_do.project_id = tool_performance.project_id
evidence_to_do.project_id = project.project_id
But the plan only seems to enforce the equality between 'project' and 'tool_performance'. So when joining the evidence_to_do, it performs a cartesian product, producing ~52B rows (estimated). That can't be fast.
Regards,
Dinesh Chandra
|Database administrator (Oracle/PostgreSQL)| Cyient Ltd. Noida.
------------------------------------------------------------------
Mobile: +91-9953975849 | Ext 1078 |dinesh.chandra@cyient.com
Plot No. 7, NSEZ, Phase-II ,Noida-Dadri Road, Noida - 201 305,India.
-----Original Message-----
From: Tomas Vondra [mailto:tomas.vondra@2ndquadrant.com]
Sent: 25 May, 2017 9:08 PM
To: Dinesh Chandra 12108 <Dinesh.Chandra@cyient.com>
Cc: pgsql-performance@postgresql.org
Subject: [EXTERNAL] Re: FW: Re: [PERFORM] Query is running very slow......
On 5/25/17 2:26 PM, Dinesh Chandra 12108 wrote:
> Hi Tomas,
>
> Please find the below input for slow query.
>
> (a) something about the hardware it's running on
> RAM-->64 GB, CPU->40core
>
> (b) amounts of data in the tables / databases
> Database size :32GB
> -----------------
> Tables size
> -----------------
> Workflow.project : 8194 byte
> workflow.tool_performance :175 MB
> workflow.evidence_to_do :580 MB
>
> (c) EXPLAIN or even better EXPLAIN ANALYZE of the query
>
> "GroupAggregate (cost=16583736169.63..18157894828.18 rows=5920110 width=69)"
> " -> Sort (cost=16583736169.63..16714893857.43 rows=52463075120 width=69)"
> " Sort Key: tool_performance.project_id, project.project_name, tool_performance.step_id, (date_trunc('day'::text, tool_performance.insert_time)), tool_performance.user_id"
> " -> Nested Loop (cost=2.42..787115179.07 rows=52463075120 width=69)"
> " -> Seq Scan on evidence_to_do (cost=0.00..119443.95 rows=558296 width=0)"
> " Filter: (status_id = ANY ('{15100,15150,15200,15300,15400,15500}'::bigint[]))"
> " -> Materialize (cost=2.42..49843.24 rows=93970 width=69)"
> " -> Hash Join (cost=2.42..49373.39 rows=93970 width=69)"
> " Hash Cond: (tool_performance.project_id = project.project_id)"
> " -> Seq Scan on tool_performance (cost=0.00..48078.88 rows=93970 width=39)"
> " Filter: ((insert_time > '2017-05-01 00:00:00+05:30'::timestamp with time zone) AND (insert_time < '2017-05-02 00:00:00+05:30'::timestamp with time zone))"
> " -> Hash (cost=1.63..1.63 rows=63 width=38)"
> " -> Seq Scan on project (cost=0.00..1.63 rows=63 width=38)"
>
Are you sure this is the same query? The query you posted includes there two join conditions:
evidence_to_do.project_id = tool_performance.project_id
evidence_to_do.project_id = project.project_id
But the plan only seems to enforce the equality between 'project' and 'tool_performance'. So when joining the evidence_to_do, it performs a cartesian product, producing ~52B rows (estimated). That can't be fast.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: Dinesh.Chandra@cyient.com, tomas.vondra@2ndquadrant.com
Subject: Re: FW: Re: Query is running very slow......
In-Reply-To: <7716a1169e2249e282a0c8527b2d502f@cyient.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