PostgreSQL database locks

postgresql

One of our CRM applications has a PostgreSQL database. Their db guys created 10 views that queries this production PostgreSQL database

  • We plan to do a SELECT query via a PHP script on each of these views at 06:15 every morning and it takes around 1 hour to execute. Part of this process is also to save the query result into a CSV
  • 06:15 is pretty close to when the users actually start using this CRM application and pretty sure these queries on the views will at times overlap on CRM application usage by users
  • Does SELECT queries on views on PostgreSQL databases lock the tables and in turn then cause any issues on the application?
  • And also the other way around if a table is locked due to application usage will this cause any issues in terms of querying the view? Or will it just skip that row?
  • I suppose it would also be best practice to monitor server load during this time? simply use TOP command on linux instance?
  • Any other concerns?

Best Answer

A query that only reads data will not block normal user activity. Readers don't block writers and vice versa.

However, it may consume substantial resouces on the database server, which could impair performance for the users.