Re: SQL is fetching results BLANK checks but the data has no BLANKS

From: M Sarwar <sarwarmd02(at)outlook(dot)com>
To: Erik Wienhold <ewie(at)ewie(dot)name>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: SQL is fetching results BLANK checks but the data has no BLANKS
Date: 2023-07-05 21:34:31
Message-ID: DM4PR19MB5978DBFB23F2A12E591D3A40D32FA@DM4PR19MB5978.namprd19.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Erik,
Table has no indexes so far.
Thanks,
Sarwar

________________________________
From: Erik Wienhold <ewie(at)ewie(dot)name>
Sent: Wednesday, July 5, 2023 5:25 PM
To: M Sarwar <sarwarmd02(at)outlook(dot)com>; pgsql-admin(at)lists(dot)postgresql(dot)org <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: SQL is fetching results BLANK checks but the data has no BLANKS

> On 05/07/2023 23:10 CEST M Sarwar <sarwarmd02(at)outlook(dot)com> wrote:
>
> Data in the database is uploaded using python.
>
> I have tried to test the same results by creating a sample table where I
> inserted some sample data. In my sample test, I do not see any discrepancies.
>
> ------------------------------
> From: M Sarwar <sarwarmd02(at)outlook(dot)com>
> Sent: Wednesday, July 5, 2023 5:01 PM
> To: pgsql-admin(at)lists(dot)postgresql(dot)org <pgsql-admin(at)lists(dot)postgresql(dot)org>
> Subject: SQL is fetching results BLANK checks but the data has no BLANKS
>
> SELECT TEST_NUMBER
> FROM BRONX.TEST_TEST_DETAILS_ALL_MCM
> WHERE LEFT(TEST_DESCRIPTION, 1) = ' '
> ;
> The above SQL is fetching lot of data but when I take closer look at the data
> in the table TEST_TEST_DETAILS_ALL_MCM, I see no prefixed BLANKS in the column
> TEST_DESCRIPTION.
>
> test_description character varying(50) COLLATE pg_catalog."default", -- TEST_DESCRIPTION, type
>
> What could be the reason here for fetching the data when I do not have the
> data which has prefixes of BLANK , ‘ ‘.

Is there a functional index on left(test_description, 1) ? My guess is that
the index is corrupted. This can be fixed with REINDEX.

--
Erik

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Erik Wienhold 2023-07-05 21:46:26 Re: SQL is fetching results BLANK checks but the data has no BLANKS
Previous Message Erik Wienhold 2023-07-05 21:25:59 Re: SQL is fetching results BLANK checks but the data has no BLANKS