user3672212
user3672212

Reputation:

What is dirty read? And How does it hinder the performance issues?

I have heard term dirty read so many times in my beginning career of development. I somehow understand it but want an expert's light on it.

Does it diminish performance issues ? or I am making wrong assumptions. Please provide its characteristic also.

Thanks in advance.

Upvotes: 1

Views: 1227

Answers (2)

Nachiket Kate
Nachiket Kate

Reputation: 8571

Yes, Definition of Dirty reads by vengets is correct. just adding some more details to it. query execution (fetching results from DB) works in below fashion,

HDD(Actual DB storage) >> Memory >> Cache >> processor

As you might be knowing, HDD is slowest in terms of performance/speed as compared to memory. performance/speed increases in terms of 'x' from LHS to RHS. so everytime when result is read from HDD, it is kept in memory/cache for usage, after modfication value are not written back to disk but they are kept in memory with the thinking that it will be used soon as again fetching from disk is time consuming.values will be written to disk to only after commit or rollback.

But before commit or rollback if other transaction reads that value then, that is called dirty read. this allows to use value from memory/cache which is fast than DB and this is how it improves performance.

If you disallow dirty reads, then everytime processor/db engine will read values from HDD which is slowest and it kills performance,reduces concurrency.

Upvotes: 0

Venkatesh K
Venkatesh K

Reputation: 4594

Quite often in database processing, we come across the situation wherein one transaction can change a value, and a second transaction can read this value before the original change has been committed or rolled back. This is known as a dirty read scenario because there is always the possibility that the first transaction may rollback the change, resulting in the second transaction having read an invalid value.

While you can easily command a database to disallow dirty reads, this usually degrades the performance of your application due to the increased locking overhead. Disallowing dirty reads also leads to decreased system concurrency.

Upvotes: 2

Related Questions