Pergunta de entrevista da empresa Revolut

Compare optimistic vs pessimistic DB locking and when to use?