Search code examples
postgresqlpostgresql-9.6

PostgreSQL select query with where clause 'COLUMN_1 is null' hangs


Recently we restored PostgreSQL database from the backup which was created without stopping database (I know this was very wrong and now we are paying the price). The backup was simple database directory backup. Now we noticed that when we execute

select *
from table
where COLUMN_1 is null

query in one of our tables the query just hangs (freezes) and never finishes. Other queries on the same table run fine and distinct(COLUMN_1) returns all the values. The same query runs correctly on the other column COLUMN_2 is null. It seems there is something wrong with that one column.

How can I repair such possibly damaged table?


Solution

  • I ran vacuum full and it solved my problem. The query now executes with is null clause on that table.