sql - How Can I perform transaction as well as not locking the table for others to perform changes? -


i making web app , want table such marks_table available time if 1 teacher uploading marks, students should not blocked see marks table.

for example student has value 5 grade in table when student performs query see grade 5

now when teacher busy transactions on table student gets no results query until teacher done because transactions locking table.

what want student gets resuls query while teacher doing transactions, see value 5 because last commited value him in table, right ? in other words, students can hit f5 , see old values until teacher commits new values, sounds normal way of doing things.

if can try : (only needs done once in database)

alter database yourdatabase set read_committed_snapshot on; 

see : https://www.brentozar.com/archive/2013/01/implementing-snapshot-or-read-committed-snapshot-isolation-in-sql-server-a-guide/

but keep in mind transactions on tables in database should kept short possible avoid problem in first place. no student complain if has wait half second results show after refreshing, complain if have wait minutes.


Comments