latches and locks - an example?
hi guys,
I keep coming across these two terms, and I am trying to conceptualise them. I understand why locks are needed on resources (this to me means tables, rows, indexes, sequences etc - maybe something else??). But I am not really sure how latches and locks fit in together. I have gathered the following from googling around.
LATCHES:
Provide only exclusive access to protected data structures
Request are not queued, if a request fails, process may try later
Simple data structure
Protect resources that are briefly needed (LRU list)
Very efficient
LOCKS:
Allow serialized access to some resources
Requests for locks are queued and serviced in order
Complex data structure that is further protected by latch
Protect resources needed for a longer time (e.g. tables)
Less efficient
If someone could give me an easy example for say a very simple table and show how the lock and latch will interact for a query on that table, it would help me a lot.
Thanks.