Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iICSs-0007s1-7n for pgsql-performance@arkaria.postgresql.org; Wed, 09 Oct 2019 13:57:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iICSp-0005z3-OB for pgsql-performance@arkaria.postgresql.org; Wed, 09 Oct 2019 13:57:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iICSp-0005yq-C1 for pgsql-performance@lists.postgresql.org; Wed, 09 Oct 2019 13:57:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iICSi-00059u-Lo for pgsql-performance@lists.postgresql.org; Wed, 09 Oct 2019 13:57:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x99Dv1Pi020081; Wed, 9 Oct 2019 09:57:01 -0400 From: Tom Lane To: =?iso-8859-9?Q?Yavuz_Selim_Serto=F0lu_=28ETIYA=29?= cc: "pgsql-performance@lists.postgresql.org" Subject: Re: Query slows when used with view In-reply-to: References: Comments: In-reply-to =?iso-8859-9?Q?Yavuz_Selim_Serto=F0lu_=28ETIYA=29?= message dated "Wed, 09 Oct 2019 12:31:40 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20079.1570629421.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 09 Oct 2019 09:57:01 -0400 Message-ID: <20080.1570629421@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =3D?iso-8859-9?Q?Yavuz_Selim_Serto=3DF0lu_=3D28ETIYA=3D29?=3D writes: > I have a problem with views. When I use view in my query it really slows= down(1.7seconds) > If I use inside of view and add conditions and joins to it, it is really= fast(0.7 milliseconds). > I have no distinct/group/partition by in view so I have no idea why is t= his happening. > I wrote queries and plans below. Those are not equivalent queries. Read up on the syntax of FROM; particularly, that JOIN binds more tightly than comma. regards, tom lane