performance - Table Locking in PostgreSQL -


i have pl/pgsql function takes data staging table our target table. process executes every night. due server restart or maintenance issues process executed manually.

the problem facing: whenever start process manually after 7 am, takes 2 hours complete (read staging table , insert target table). whenever executes per schedule, i.e., before 7 am, takes 22-25 minutes on average.

what issue? if required, can share function snippet here.

the typical reason general concurrent activity in database, competes same resources function , may cause lock contention. check db log activities starting around 7 a.m.

the postgres wiki on lock monitoring

a function runs single transaction. locks acquired along way , released @ end of transaction. makes long running functions particularly vulnerable lock contention.

you may able optimize general performance behavior towards concurrent transactions make run faster. or more radically: if @ possible, split big function in separate parts, call in separate transactions.

how split huge updates:

there additional things consider when packing multiple big operations single function:


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -