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 1kIz8r-0005p4-B1 for pgsql-general@arkaria.postgresql.org; Thu, 17 Sep 2020 19:00:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIz8p-0003TX-Ny for pgsql-general@arkaria.postgresql.org; Thu, 17 Sep 2020 19:00:23 +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 1kIz8p-0003TP-GB for pgsql-general@lists.postgresql.org; Thu, 17 Sep 2020 19:00:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIz8n-0006Df-Ac for pgsql-general@lists.postgresql.org; Thu, 17 Sep 2020 19:00:23 +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 08HIxl7d236994; Thu, 17 Sep 2020 14:59:47 -0400 From: Tom Lane To: Ben cc: Jerry Sievers , pgsql-general@lists.postgresql.org Subject: Re: Obvious data mismatch in View2 which basically SELECT * from View1 In-reply-to: References: <6db031b4-58fa-466c-b73d-1dc0a4bf97d6@outlook.com> <87zh5opis3.fsf@jsievers.enova.com> Comments: In-reply-to Ben message dated "Fri, 18 Sep 2020 01:38:35 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <236992.1600369187.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Sep 2020 14:59:47 -0400 Message-ID: <236993.1600369187@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ben writes: > You are right none of them is what I originally used to create them = > which should be > `select * from utlog.stats_per_shift_filtered_b0206`, but they do look = > different, This discrepancy could explain a lot: > =C2=A0=C2=A0=C2=A0=C2=A0 (stats_per_shift_filtered_u0206.wsft)::charact= er varying AS wsft, vs > =C2=A0=C2=A0=C2=A0=C2=A0 stats_per_shift_filtered_b0206.wsft, Your problem query has a WHERE clause testing wsft, so this difference is subtly affecting what that WHERE clause means. That could result in a plan change, thereby changing the row output order, which as already noted would be sufficient to explain the inconsistency. If I had to bet I'd suspect that the extra cast is blocking use of an index on wsft. regards, tom lane