Prasad Kanaparthi
Prasad Kanaparthi

Reputation: 6563

How to add NOLOCK for Auto generated SQL queries in Loopback 3

I'm using Loopback 3 and SQL. We've 20 million rows in SQL tables and when we query data using Loopback it's taking a lot of time and further observation we found queries are blocking in SQL. Noticed that the Loopback auto generated queries doesn't have any WITH (NOLOCK). How to add WITH (NOLOCK) for every SELECT query?

Upvotes: 1

Views: 167

Answers (1)

Rifa Achrinza
Rifa Achrinza

Reputation: 1585

Using Transaction.READ_UNCOMMITTED would produce WITH (NOLOCK).

For example:

YourModel.beginTransaction({isolationLevel: YourModel.Transaction.READ_UNCOMMITTED}, (err, tx) => {
  // Now we have a transaction (tx)
  // Write the queries here
  // Then run commit the transaction:
  tx.commit(err => {});
});

See the docs for more details.

Upvotes: 1

Related Questions