Postgres 9.6: Inserts very slow after reboot

梦想与她 提交于 2019-12-24 21:27:53

问题


I'm experiencing a strange issue when importing data into postgres. I have an import script that runs once daily at night via cronjob on a Linux OS (Linux 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux). The process reads a file containing about 2 million rows and inserts these into a table in batches (batch size 25.000). This takes roughly 2 to 2.5 minutes, which is absolutely reasonable. The table has 3 indexes and meanwhile contains more than 130M rows. To increase the performance I declared the table as UNLOGGED and disabled WAL. From time to time I need to upgrade the system which requires a server restart. This somehow affects the database as the data import suddenly takes instead of minutes about 1 to 1.5 hours. I couldn't find out any reason for this. What's going wrong here, any ideas?


回答1:


This happened to me once. Don't really know why, but for me it was fixed after restarting the postgresql service. My thinking says that if you do not restart the service(even after a reboot), it seems postgres keeps its WAL (Write-Ahead Logging). By restarting the service everything cleans up, so everything runs as good as new again. But, perhaps there's another reason. Anyway, try restarting the service instead of rebooting or restart the service after reboot.

Read the question comments for more info or this link that @user35934 posted.



来源:https://stackoverflow.com/questions/48328237/postgres-9-6-inserts-very-slow-after-reboot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!