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 1jqzWs-0002eh-1v for pgsql-general@arkaria.postgresql.org; Thu, 02 Jul 2020 13:45:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jqzWL-0006CY-Kg for pgsql-general@arkaria.postgresql.org; Thu, 02 Jul 2020 13:44:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqzWL-0006Be-Cx for pgsql-general@lists.postgresql.org; Thu, 02 Jul 2020 13:44:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqzWF-0006vl-6U for pgsql-general@lists.postgresql.org; Thu, 02 Jul 2020 13:44:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 062Din5d849798; Thu, 2 Jul 2020 09:44:49 -0400 From: Tom Lane To: Anders Steinlein cc: pgsql-general@lists.postgresql.org Subject: Re: Different results from identical matviews In-reply-to: References: <815598.1593648137@sss.pgh.pa.us> Comments: In-reply-to Anders Steinlein message dated "Thu, 02 Jul 2020 13:26:22 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <849796.1593697489.1@sss.pgh.pa.us> Date: Thu, 02 Jul 2020 09:44:49 -0400 Message-ID: <849797.1593697489@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Anders Steinlein writes: > On Thu, Jul 2, 2020 at 2:02 AM Tom Lane wrote: >> I suspect the query underlying the matviews is less deterministic than >> you think it is. > Thanks for the tip, but I'm having a hard time thinking that's the case, > seeing as I'm unable to trigger the wrong result no matter how hard I try > with a new definition/manual query. Well, another line of thought is that there actually is some difference between the stored query for the original matview and the ones you enter afresh. You said they were the same, but I surely didn't attempt to verify that. Comparing pg_get_viewdef() output for equality would be a good first step. Even that perhaps isn't conclusive, so you could also try comparing the pg_rewrite.ev_action fields for the views' ON SELECT rules. (That might be a bit frustrating because of likely inconsistencies in node "location" fields; but any other difference is cause for suspicion.) regards, tom lane