Hi,
I'm seeing some interesting behaviour in postgres when I inserted some 50000 records into a table in 2 minutes.
After the insertion a certain query on the table which also makes joins to several other tables is hanging on for ever and postgres consumes 98% of the cpu; however, postgres is answering queries on other tables and even simple queries on the table into which the bulk insertion happened.
We observed that the query is not even put in the execution que, and is getting stuck some where in the parser stage,I guess.
However, when we trried running the same query after keeping the system idle for two days, to our surprise it worked pretty quickly( 2 seconds).
After some googling, we figured out that running 'analyze' or 'vacuum' immediately after bulk insertion solves the hang issue.
My questions: Is this a known limitation of Postgres? Should we run this vacuum or analyze on tables everytime when we execute bulk insertion?
Or can we enable Autvauum? If we have to enable autovacuum, what is the impact on the application performance and/or transaction handling?
Can some one help me in dealing with the situation mentioned above?
Thanks and Regards,
Samba