We are live about 2 years with our WEB APIs and suddenly some high load made our one API work very slow and DBA says that it's because of Cursor sharing problem which itself is because of NLS parameters are changing.
API just uses EF Core 2.1 with Devart provider (9.6.621) for oracle to make simple query :
public IQueryable<NotificationEndUserViewEntity> InboxQuerable(string userId, string clientId)
{
var client = _dbContext.Clients.FirstOrDefault(x => x.ClientId == clientId);
var inboxQuerable = _dbContext
.NotificationsUserView
.Where(nots =>
!nots.IsCancelled &&
!nots.IsDeleted &&
nots.IsOutGoing &&
nots.ActiveFrom < DateTime.Now &&
(nots.ActiveTill == null || nots.ActiveTill > DateTime.Now) &&
nots.ClientId == client.Id &&
nots.RecipientId == userId);
return inboxQuerable.AsNoTracking();
}
var firstMastRead = await InboxQuerable(userId, clientId)
.OrderByDescending(x => x.ActiveFrom)
.FirstOrDefaultAsync(x => x.IsMustRead && !x.IsRead);
What can be the problem here? DBA says that there more then 300-500 cursors for this query. Is it prameter binding problem, EF or Devart (We use old versions but before update we hav to be sure about it), how can I control NLS settings?
UPDATE: which DBA sees.
SELECT nots.Id,
nots.ActiveFrom,
nots.ActiveTill,
nots.BodyEn,
nots.BodyKa,
nots.ClientId,
nots.HasAttachment,
nots.IsCancelled,
nots.IsDeleted,
nots.IsMustRead,
nots.IsNoReplay,
nots.IsOutGoing,
nots.IsRead,
nots.RecipientId,
nots.SubjectEn,
nots.SubjectKa
FROM VW_USER_NOTIFICATIONS nots
WHERE ( ( ( ( ( ( (nots.IsCancelled = :"SYS_B_0")
AND (nots.IsDeleted = :"SYS_B_1"))
AND (nots.IsOutGoing = :"SYS_B_2"))
AND (nots.ActiveFrom < CURRENT_DATE))
AND ( nots.ActiveTill IS NULL
OR (nots.ActiveTill > CURRENT_DATE)))
AND (nots.ClientId = :p__client_Id_0))
AND (nots.RecipientId = :p__userId_1))
AND ((nots.IsMustRead = :"SYS_B_3") AND (nots.IsRead = :"SYS_B_4"))
ORDER BY nots.ActiveFrom DESC FETCH FIRST :"SYS_B_5" ROWS ONLY
Which is generated by Linq :
SELECT
nots.Id,
nots.ActiveFrom,
nots.ActiveTill,
nots.BodyEn,
nots.BodyKa,
nots.ClientId,
nots.HasAttachment,
nots.IsCancelled,
nots.IsDeleted,
nots.IsMustRead,
nots.IsNoReplay,
nots.IsOutGoing,
nots.IsRead,
nots.RecipientId,
nots.SubjectEn,
nots.SubjectKa FROM VW_USER_NOTIFICATIONS nots WHERE (((((((nots.IsCancelled = 0)
AND (nots.IsDeleted = 0))
AND (nots.IsOutGoing = 1))
AND (nots.ActiveFrom < CURRENT_DATE))
AND (nots.ActiveTill IS NULL OR (nots.ActiveTill > CURRENT_DATE)))
AND (nots.ClientId = :p__client_Id_0))
AND (nots.RecipientId = :p__userId_1))
AND ((nots.IsMustRead = 1) AND (nots.IsRead = 0)) ORDER BY nots.ActiveFrom DESC FETCH FIRST 1 ROWS ONLY