The PG database is the PostgreSQL database.
A few days ago in a Java project, the data table exception hangs for the PG database after running the Java program. And it appears on a computer, reloading the database is useless, the other computers can not reproduce, is a very strange phenomenon.
The main performance of the exception hangs is:
1. Using Pgadmin to select the appropriate table will result in pgadmin not responding and cannot be recovered for a long time.
2, using pgadmin Direct SQL command additions and deletions can not be executed, the execution took time from dozens of milliseconds to a few minutes, is expected to continue to grow.
3, only restart the PostgreSQL service in order to let the abnormal data table return to normal, restore to both can be selected, but also through the SQL statement additions and deletions to the search.
Finally, it is determined that because Java uses the TRUNCATE command to clear the data table operation caused the data table exception hangs, and then replaced the truncate command with the Delete command is OK.
During the troubleshooting process, you can use the truncate command in Pgadmin to directly clean up the table where the exception occurs, and to reproduce the previous problem, and delete is used normally.
The difference between truncate, delete, and drop is attached below: the difference between drop, truncate, and delete
As for this special case, why does the truncate cause the data table to hang, I have not thought to understand, hoped that the person who knows can help to guide the maze.
PG Database Data table exception hangs