Re: FW: Query execution failure

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pete Storer <Pete(dot)Storer(at)sas(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: FW: Query execution failure
Date: 2023-01-26 16:06:41
Message-ID: 2961799.1674749201@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Pete Storer <Pete(dot)Storer(at)sas(dot)com> writes:
> I'm not sure how to identify which index may be corrupt, if that is the cause. Regarding a different sort order between tables, if that were the case, wouldn't this query fail in Production as it does in our Development environment? They are identical with respect to indices and sort order, and they both point to the same foreign table, which resides on a MySQL database.

Meh. You've just got two merge joins in that plan, and three of the
four inputs to them are being explicitly sorted, so one would certainly
hope that those sorts are consistent. But the fourth input is being
sourced directly from the foreign server, and so this query is
fundamentally assuming that the foreign server has the same idea of
sort ordering as the local one. Evidently that assumption is wrong.

I'd check locale settings on your two databases to understand why
it doesn't fail on prod. But the long-term solution if you want this
to work reliably is probably to force use of C locale on all three
databases; that's about the only locale that you can fully trust
to be portable.

I don't know anything about the mysql FDW, but another possible route
to fixing things is to get it to not believe that the remote's sort
ordering matches the local one. If the plan were relying on a local
sort instead of a remote sort then everything would be fine.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-01-27 09:27:35 BUG #17761: Questionable regular expression behavior
Previous Message Pete Storer 2023-01-26 15:43:37 RE: FW: Query execution failure