Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDrsz-0002NT-IR for pgsql-performance@arkaria.postgresql.org; Thu, 25 May 2017 12:29:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dDrsz-0001re-28 for pgsql-performance@arkaria.postgresql.org; Thu, 25 May 2017 12:29:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dDrrF-0007BC-CJ for pgsql-performance@postgresql.org; Thu, 25 May 2017 12:27:13 +0000 Received: from mxgate01.infotech-enterprises.com ([110.76.168.168] helo=mxgate01.cyient.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dDrrB-00082i-2n for pgsql-performance@postgresql.org; Thu, 25 May 2017 12:27:12 +0000 X-IronPort-AV: E=Sophos;i="5.38,391,1491244200"; d="scan'208";a="73474159" Subject: FW: Re: Query is running very slow...... Received: from unknown (HELO CYINMBX4.CORP.CYIENT.COM) ([172.17.4.164]) by mxgate01.cyient.com with ESMTP/TLS/AES256-SHA256; 25 May 2017 17:55:37 +0530 Received: from CYINMBX4.CORP.CYIENT.COM (172.17.4.164) by CYINMBX4.CORP.CYIENT.COM (172.17.4.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.544.27; Thu, 25 May 2017 17:56:54 +0530 Received: from CYINMBX4.CORP.CYIENT.COM ([fe80::596e:284a:a6f6:e6d4]) by CYINMBX4.CORP.CYIENT.COM ([fe80::596e:284a:a6f6:e6d4%19]) with mapi id 15.01.0544.027; Thu, 25 May 2017 17:56:54 +0530 From: Dinesh Chandra 12108 To: Tomas Vondra CC: "pgsql-performance@postgresql.org" Thread-Topic: [EXTERNAL] Re: [PERFORM] Query is running very slow...... Thread-Index: AdLUr7wP8JB03M/+QSqKr/Q3/zGYkP//qewA//5lixA= Date: Thu, 25 May 2017 12:26:54 +0000 Message-ID: <39b30cfde27a48898340a69940581727@cyient.com> References: <3152be5a435f45649cef6bf9321beb9a@cyient.com> <4caed7cc-07d8-e364-78ca-7a96b9780a9d@2ndquadrant.com> In-Reply-To: <4caed7cc-07d8-e364-78ca-7a96b9780a9d@2ndquadrant.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.17.4.81] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Pg-Spam-Score: -3.5 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org 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=3D16583736169.63..18157894828.18 rows=3D5920110 widt= h=3D69)" " -> Sort (cost=3D16583736169.63..16714893857.43 rows=3D52463075120 widt= h=3D69)" " 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=3D2.42..787115179.07 rows=3D52463075120 wid= th=3D69)" " -> Seq Scan on evidence_to_do (cost=3D0.00..119443.95 rows= =3D558296 width=3D0)" " Filter: (status_id =3D ANY ('{15100,15150,15200,15300,= 15400,15500}'::bigint[]))" " -> Materialize (cost=3D2.42..49843.24 rows=3D93970 width= =3D69)" " -> Hash Join (cost=3D2.42..49373.39 rows=3D93970 wid= th=3D69)" " Hash Cond: (tool_performance.project_id =3D proj= ect.project_id)" " -> Seq Scan on tool_performance (cost=3D0.00..= 48078.88 rows=3D93970 width=3D39)" " Filter: ((insert_time > '2017-05-01 00:00:= 00+05:30'::timestamp with time zone) AND (insert_time < '2017-05-02 00:00:0= 0+05:30'::timestamp with time zone))" " -> Hash (cost=3D1.63..1.63 rows=3D63 width=3D3= 8)" " -> Seq Scan on project (cost=3D0.00..1.6= 3 rows=3D63 width=3D38)" (d) configuration of the database (work_mem, shared_buffers etc.) work_mem =3D 32MB shared_buffers =3D 16GB maintenance_work_mem =3D 8GB temp_buffers =3D 64MB max_connections=3D2000=09 Regards, Dinesh Chandra |Database administrator (Oracle/PostgreSQL)| Cyient Ltd. Noida. ------------------------------------------------------------------ Mobile: +91-9953975849 | Ext 1078 |dinesh.chandra@cyient.com=20 Plot No. 7, NSEZ, Phase-II ,Noida-Dadri Road, Noida - 201 305,India. -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owne= r@postgresql.org] On Behalf Of Tomas Vondra Sent: 24 May, 2017 10:56 PM To: pgsql-performance@postgresql.org Subject: [EXTERNAL] Re: [PERFORM] Query is running very slow...... Hi, On 5/24/17 7:04 PM, Dinesh Chandra 12108 wrote: > Dear Expert, >=20 > While executing the blow query, its taking too long time to fetch output. >=20 > Could you please help to fine tune the same? >=20 You'll have to provide far more details - the query alone is certainly not = enough for anyone to guess why it's slow. Perhaps look at this: https://wiki.postgresql.org/wiki/Slow_Query_Questions In particular, you'll have to tell us (a) something about the hardware it's running on (b) amounts of data in the tables / databases (c) EXPLAIN or even better EXPLAIN ANALYZE of the query (d) configuration of the database (work_mem, shared_buffers etc.) regards --=20 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 --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance