Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YXqG2-0001gV-NW for pgsql-performance@arkaria.postgresql.org; Tue, 17 Mar 2015 12:06:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YXqG2-0001wS-5n for pgsql-performance@arkaria.postgresql.org; Tue, 17 Mar 2015 12:06:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YXqFz-0001wI-Io for pgsql-performance@postgresql.org; Tue, 17 Mar 2015 12:06:00 +0000 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YXqFq-0006Im-IJ for pgsql-performance@postgresql.org; Tue, 17 Mar 2015 12:05:57 +0000 Received: by oibu204 with SMTP id u204so6043532oib.0 for ; Tue, 17 Mar 2015 05:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zetainteractive.com; s=google; h=reply-to:from:references:in-reply-to:mime-version:thread-index:date :message-id:subject:to:cc:content-type; bh=bNcoi+H4JXHHnCNgO02LJNE8i0xGLakZEZ7ERTt9jy8=; b=NLT3fFFZvltxTpPFyq1G4RW50hrsn7HDHSwd3S763XRzxcf1cSnJI4+e/r+BP/zu9X MS2MXzIpvx7mhX5WPapr72fwA6BE1Ke1/cmMqyHXxova8on0H2yAPkMWOlTUaETGMEPu u3K1EnaY3yZtwZ1T5wN7FGt70B3P4yMdz6enU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:reply-to:from:references:in-reply-to :mime-version:thread-index:date:message-id:subject:to:cc :content-type; bh=bNcoi+H4JXHHnCNgO02LJNE8i0xGLakZEZ7ERTt9jy8=; b=KmHUTusxM/XZN/h0YjEodPCz7ZTm0u/hzrMaBTA9m2//l6gN+mCrwWujoq9vrzfg5h okM68lG5oSVH0LjO+8fZTOkRgrtWBNgvWkTr1tBTXZJhpMtHegnxf7cIVyOP/S/3gMWZ IRQXD6AyP8439J8UN8Ms1IT4dvCZ8LZdYSe1CAWdd+JA+LAiCDnwNBQpnoUyGYkKhQtB sB9TE+qU/ea+Nt3Ja+1Icbnz8Hf6KsP59owWnhOvUh3BcYBPAxsJ9ns2nfZOk2P3KUwV yXrjd5VRJv3s0P7/Du/vy4L8UOPxAXQ390DMZzKhCsombXS3O11AnM67wGOf2TXABx6E C1WA== X-Gm-Message-State: ALoCoQlfNT+p0M1mYF8Xns0KZE0Y4j/GVyHyoywL6fvlpZaJ6Rnt0O7ZvgASFqKu2T4MiGTHXfyR X-Received: by 10.202.53.84 with SMTP id c81mr48952823oia.120.1426593947808; Tue, 17 Mar 2015 05:05:47 -0700 (PDT) Reply-To: From: Vivekanand Joshi References: <84a6fe4be04c3ef0a714851977860ac8@mail.gmail.com> <160b8780d89add7f23c4eb9c3debb99d@mail.gmail.com> <55034A48.4040409@2ndquadrant.com> <849e75d9463938372dd4c516f5c5d89c@mail.gmail.com> <55037CEA.5050906@2ndquadrant.com> <55073272.20209@BlueTreble.com> <55074424.9050506@2ndquadrant.com> <55076FFB.9090105@BlueTreble.com> c5231342781287ff8cbc9ac1f20ff036@mail.gmail.com <61a7a27428e588411e8ac1817043205c@mail.gmail.com> <550813CD.7040605@2ndquadrant.com> In-Reply-To: <550813CD.7040605@2ndquadrant.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 thread-index: AQGXPdRf3VxuG24kJ8WwflsQcHnAgQJFdAGLAd7f+TAB3+I8LgHxOMQ4AZdEQFACZq94KAEoF2rjAunz58UBLhBnRQIZ3EmNAZo17EoBofTzdgDeIilzApfZn0sB7x5cEJyzYK/w Date: Tue, 17 Mar 2015 17:35:46 +0530 Message-ID: Subject: Re: Performance issues To: Tomas Vondra , Jim Nasby , Scott Marlowe , Varadharajan Mukundan Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) 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, This is what I am getting, EXPLAIN ANALYZE SELECT * FROM s_f_promotion_history WHERE (send_dt >= '2014-03-13 00:00:00'); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on s_f_promotion_history (cost=0.00..283333.66 rows=1 width=74) (actual time=711.023..1136.393 rows=1338 loops=1) Filter: ((send_dt >= '2014-03-13 00:00:00'::timestamp without time zone) AND (send_dt <= '2015-03-14 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 9998662 Total runtime: 1170.682 ms CREATE INDEX idx_pr_history ON S_F_PROMOTION_HISTORY(touchpoint_execution_id, send_dt); After Creating Index: QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using idx_pr_history on s_f_promotion_history (cost=0.43..254028.45 rows=1 width=74) (actual time=375.796..604.587 rows=1338 loops=1) Index Cond: ((send_dt >= '2014-03-13 00:00:00'::timestamp without time zone) AND (send_dt <= '2015-03-14 00:00:00'::timestamp without time zone)) Total runtime: 604.733 ms The query I gave you is the smallest query, it is using two views and both the views I have changed by using subqueries instead of CTEs. When I join these two views, it is not getting completed at all. Explain analyze plan for view s_v_f_promotion_history_email: http://explain.depesz.com/s/ure Explain analyze plan for view s_v_d_campaign_hierarchy : http://explain.depesz.com/s/WxI Regards, Vivek -----Original Message----- From: Tomas Vondra [mailto:tomas.vondra@2ndquadrant.com] Sent: Tuesday, March 17, 2015 5:15 PM To: vjoshi@zetainteractive.com; Jim Nasby; Scott Marlowe; Varadharajan Mukundan Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Performance issues On 17.3.2015 12:07, Vivekanand Joshi wrote: > EXPLAIN ANALYZE didn't give result even after three hours. In that case the only thing you can do is 'slice' the query into smaller parts (representing subtrees of the plan), and analyze those first. Look for misestimates (significant differences between estimated and actual row counts, and very expensive parts). We can't do that, because we don't have your data or queries, and without the explain analyze it's difficult to give advices. -- 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