Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgFKZ-0003qo-9A for pgsql-admin@arkaria.postgresql.org; Tue, 02 Jun 2020 22:24:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jgFKX-0002VA-HR for pgsql-admin@arkaria.postgresql.org; Tue, 02 Jun 2020 22:24:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgFKX-0002V3-9L for pgsql-admin@lists.postgresql.org; Tue, 02 Jun 2020 22:24:21 +0000 Received: from impout009aa.msg.chrl.nc.charter.net ([47.43.20.33] helo=impout009.msg.chrl.nc.charter.net) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jgFKU-0000ic-Py for pgsql-admin@postgresql.org; Tue, 02 Jun 2020 22:24:20 +0000 Received: from cerberus.crazybean.net ([24.151.69.73]) by cmsmtp with ESMTP id gFKRjqx902HYJgFKRjNoEW; Tue, 02 Jun 2020 22:24:16 +0000 Authentication-Results: crazybean.net; none X-Authority-Analysis: v=2.3 cv=AKi/Lllh c=1 sm=1 tr=0 a=YXTuGtgWN9YX+aIhe8tYuA==:117 a=YXTuGtgWN9YX+aIhe8tYuA==:17 a=xqWC_Br6kY4A:10 a=nTHF0DUjJn0A:10 a=bmULpPF2AAAA:8 a=tpbCY0XfzwhPJoJfZ1wA:9 a=QEXdDO2ut3YA:10 a=uzG7etNRGgV1OsClQs8A:9 a=kqAnd0BaQ9k7EBq5:21 a=_W_S_7VecoQA:10 a=LwXMS3FhJVUSL8bnO8p6:22 Received: from [IPv6:2001:470:e117:4:e4a4:d450:1855:a0d3] ( [2001:470:e117:4:e4a4:d450:1855:a0d3]) by cerberus.crazybean.net (OpenSMTPD) with ESMTPSA id 5c854c7c (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 2 Jun 2020 18:24:14 -0400 (EDT) From: Rui DeSousa Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_CF3FD4FB-5459-4021-9AC4-0189905386A0" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: trying to build immutable function in index Date: Tue, 2 Jun 2020 18:24:14 -0400 In-Reply-To: Cc: pgsql-admin To: Mark Steben References: X-Mailer: Apple Mail (2.3608.80.23.2.2) X-CMAE-Envelope: MS4wfFGzR5H/Y9+C+tRu97WfovR/e3NDuaHXPHfYvYlvMpp11l/8nscACr9f3eJwvbtjNi7+5+D/PWfB6PoQ1t9izv8abUhM7cz1xtEYLnVSHtAR358pmzGM RxyuHtfkska34uC7mUTfkZ8OsxjshZDs9Zn/kuGK6subbSx9+Nv/yvY+VLoEb/CfHcQeDhY9StoI3EQHc3MlOXBiP6XQQMdfzR5amFm6S+xeufZphJBF/Byx List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_CF3FD4FB-5459-4021-9AC4-0189905386A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 2, 2020, at 5:42 PM, Mark Steben = wrote: >=20 > AND value::date >=3D date_trunc('MONTH'::text, 'now'::text::date - '1 = mon'::interval month) I don=E2=80=99t think value::date is immutable; it will return a = different date depending on your timezone.=20 Also this is also not immutable: 'now'::text::date - '1 mon'::interval = month=20 You would have records indexed that should not be indexed the next month = basically invalidating itself each month. --Apple-Mail=_CF3FD4FB-5459-4021-9AC4-0189905386A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jun 2, 2020, at 5:42 PM, Mark Steben <mark.steben@drivedominion.com> wrote:

AND value::date >=3D date_trunc('MONTH'::text, = 'now'::text::date - '1 mon'::interval month)

I don=E2=80=99t think value::date is = immutable; it will return a different date depending on your = timezone. 

Also this is also not immutable:  'now'::text::date - '1 mon'::interval = month 

You would have records indexed that should not be indexed the = next month basically invalidating itself = each month.


= --Apple-Mail=_CF3FD4FB-5459-4021-9AC4-0189905386A0--