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 1hxJ2t-0004lc-JU for pgsql-performance@arkaria.postgresql.org; Mon, 12 Aug 2019 22:44:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxJ2s-0001Qz-7k for pgsql-performance@arkaria.postgresql.org; Mon, 12 Aug 2019 22:44:06 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxJ2r-000135-Ss for pgsql-performance@lists.postgresql.org; Mon, 12 Aug 2019 22:44:05 +0000 Received: from hm1481-n-165.locaweb.com.br ([189.126.112.165]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxJ2n-0006ni-6s for pgsql-performance@lists.postgresql.org; Mon, 12 Aug 2019 22:44:03 +0000 Received: from mcbain0013.correio.biz (189.126.112.18) by hm1481.locaweb.com.br id ha7lp6169v07 for ; Mon, 12 Aug 2019 19:43:27 -0300 (envelope-from ) Received: from moe0166.email.locaweb.com.br (unknown [10.31.120.111]) by mcbain0013.correio.biz (Postfix) with ESMTP id 91406D40075; Mon, 12 Aug 2019 19:43:49 -0300 (-03) x-locaweb-id: qyHzKK_R8aWhjwoIerpCUhsi5PfCUymhK53qXIAegdcRogeYX3-XTadcSpgGGxitWQf3rKGbFuqvLmn5XdJ_XeDnSC7FYZn7HbLXpGF-9Ijnyhi0HYcMFDJYmHUvxBBkNpCEMoE-bP6ezYctSSAGAiUQTdcn44n38CMMTur8AtK2CBQxYrL8BXB-mYlvBizJAEF_8856gTBS-um1KjH5QQ== NmM3NTY5NzM3MjZmNjI2NTcyNzQ2ZjQwNzM2OTczNjM2ZjYyNzI2MTJlNjM2ZjZkMmU2Mjcy x-locaweb-id: qyHzKK_R8aWhjwoIerpCUhsi5PfCUymhK53qXIAegdcRogeYX3-XTadcSpgGGxitWQf3rKGbFuqvLmn5XdJ_XeDnSC7FYZn7HbLXpGF-9Ijnyhi0HYcMFDJYmHUvxBBkNpCEMoE-bP6ezYctSSAGAiUQTdcn44n38CMMTur8AtK2CBQxYrL8BXB-mYlvBizJAEF_8856gTBS-um1KjH5QQ== NmM3NTY5NzM3MjZmNjI2NTcyNzQ2ZjQwNzM2OTczNjM2ZjYyNzI2MTJlNjM2ZjZkMmU2Mjcy X-AuthUser: luisroberto@siscobra.com.br Received: from moe0166.webmail-seguro.com.br (localhost [IPv6:::1]) (Authenticated sender: luisroberto@siscobra.com.br) by moe0166.email.locaweb.com.br (Postfix) with ESMTPA id AB7AB50001C; Mon, 12 Aug 2019 19:43:54 -0300 (-03) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_98d3dd53e298a8f7cc33d5de1b6459c7" Date: Mon, 12 Aug 2019 19:43:54 -0300 From: =?UTF-8?Q?Lu=C3=ADs_Roberto_Weck?= To: Michael Lewis Cc: pgsql-performance@lists.postgresql.org Subject: Re: Organization: Siscobra Sistemas In-Reply-To: References: <3fba6c11d158490b07afebc5a21c7aa9@siscobra.com.br> Message-ID: X-Sender: luisroberto@siscobra.com.br User-Agent: Roundcube Webmail/1.3.8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_98d3dd53e298a8f7cc33d5de1b6459c7 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII > It seems like it should be- > > SELECT * FROM users u JOIN last_user_event_1 e USING (user_id,user_group); > --OR-- > SELECT * FROM last_user_event_2 e; > > for them to produce the same result set, since the last_user_event_2 already (could) have users info in it very simply by select * instead of e.* in that view definition. > > Are there other important joins/where/order by/limits that would be on this "main query" that is just SELECT * FROM ____ right now which you have dropped to try to simplify the example? You're right about the queries, I made a mistake. Yes, I'm going to filter them by user_id and user_group, possibly (but not likely) using LIMIT 1. In the explain examples I am using user_id = 1272897 and user_group = 19117 --=_98d3dd53e298a8f7cc33d5de1b6459c7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

It seems like it should be-

SELECT * FROM users u JOIN last_user_event_1 e USING (user_i= d,user_group);
--OR--
SELECT * FROM last_user_event_2 e;
 
for them to produce the same result set, since the last_user_event_2 a= lready (could) have users info in it very simply by select * instead of e= =2E* in that view definition.
 
Are there other important joins/where/order by/limits that would be on= this "main query" that is just SELECT * FROM ____ right now which you have= dropped to try to simplify the example?

You're right about the queries, I made a mistake.

Yes, I'm going to filter them by user_id and user_group, possibly (but n= ot likely) using LIMIT 1. In the explain examples I am using user_id =3D&nb= sp;1272897 and user_group =3D 19117

--=_98d3dd53e298a8f7cc33d5de1b6459c7--