Re: Obvious data mismatch in View2 which basically SELECT * from View1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ben <bentenzha(at)outlook(dot)com>
Cc: Jerry Sievers <gsievers19(at)comcast(dot)net>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Obvious data mismatch in View2 which basically SELECT * from View1
Date: 2020-09-17 18:59:47
Message-ID: 236993.1600369187@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben <bentenzha(at)outlook(dot)com> <MWHPR06MB2400E1FA4AAD12440EA96B79B93E0(at)MWHPR06MB2400(dot)namprd06(dot)prod(dot)outlook(dot)com> 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:

>      (stats_per_shift_filtered_u0206.wsft)::character varying AS wsft,

vs

>      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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaozhong SHI 2020-09-17 22:59:26 Postgres as a service for supporting common application users
Previous Message Ben 2020-09-17 17:38:35 Re: Obvious data mismatch in View2 which basically SELECT * from View1