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 1hxJME-0005U6-C7 for pgsql-performance@arkaria.postgresql.org; Mon, 12 Aug 2019 23:04:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxJMD-0001Py-8a for pgsql-performance@arkaria.postgresql.org; Mon, 12 Aug 2019 23:04:05 +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 1hxJMC-0001PW-Vq for pgsql-performance@lists.postgresql.org; Mon, 12 Aug 2019 23:04:05 +0000 Received: from mail49155.hm1315.locaweb.com.br ([201.76.49.155]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxJM8-0006zx-Ov for pgsql-performance@lists.postgresql.org; Mon, 12 Aug 2019 23:04:04 +0000 Received: from mcbain0012.correio.biz (189.126.112.16) by mail4950.hm1315.locaweb.com.br id ha7o6e16a0op for ; Mon, 12 Aug 2019 20:04:03 -0300 (envelope-from ) Received: from moe0166.email.locaweb.com.br (unknown [10.31.120.111]) by mcbain0012.correio.biz (Postfix) with ESMTP id 13D658C0378; Mon, 12 Aug 2019 20:03:42 -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 63EDF50001C; Mon, 12 Aug 2019 20:03:54 -0300 (-03) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_01aac090e1cea683a656885914816670" Date: Mon, 12 Aug 2019 20:03:54 -0300 From: =?UTF-8?Q?Lu=C3=ADs_Roberto_Weck?= To: Michael Lewis Cc: pgsql-performance@lists.postgresql.org Subject: Re: Last event per user Organization: Siscobra Sistemas In-Reply-To: References: <3fba6c11d158490b07afebc5a21c7aa9@siscobra.com.br> Message-ID: <1ab9f8c65040b2e724e559ce9bc0b8cd@siscobra.com.br> 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 --=_01aac090e1cea683a656885914816670 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII > If you modify last_user_event_2 to select user and event info in the view, and just put there where clause directly on the view which is not joined to anything, instead of on the "extra copy" of the users table like you were showing previously, I would expect that the performance should be excellent. But I need user_id and user_group to be outside of the view definition. user_id and user_group are dynamic values, as in, I need to call this query multiple times for different user_ids and user_groups . --=_01aac090e1cea683a656885914816670 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

If you modify last_user_event_2 to select user and event info in th= e view, and just put there where clause directly on the view which is not j= oined to anything, instead of on the "extra copy" of the users table like y= ou were showing previously, I would expect that the performance should be e= xcellent.

But I need user_id and user_group to be outside of the view definition= =2E user_id and user_group are dynamic values, as in, I need to call this q= uery multiple times for different user_ids and user_groups .

--=_01aac090e1cea683a656885914816670--