Newer Version Available
Apex Limit Event Object
ApexLimitEvent represents an Apex execution
governor limit. This object is available in API version 36.0 and later.
When an Apex trigger, class, component, or Visualforce page produces non-zero governor limits, the results are stored in this object.
Fields
| Field | Details |
|---|---|
| EntryPointId |
|
| EntryPointName |
|
| EntryPointType |
|
| EventDate |
|
| ExecutionIdentifier |
|
| LimitType |
|
| LimitValue |
|
| NamespacePrefix |
|
| UserId |
|
| Username |
|
SOQL Usage
WHERE is the only supported SOQL function on Apex
Limit Event Object, and you can use comparison operators (<, >, <=, and >=) only
in the final expression of a WHERE clause. The !=
operator isn’t supported.
Apex Limit Event Object allows filtering over five fields: EventDate, UserId, EntryPointId, EntryPointType, and Id. There’s a
catch here; your query won’t work unless you use the correct order and combination of
these fields. The following list provides some examples of valid and invalid queries:
-
Unfiltered
-
Valid—Contains no WHERE
clause, so no special rules
apply.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent
-
Valid—Contains no WHERE
clause, so no special rules
apply.
-
Filtered on EventDate—you can filter solely on
EventDate, but single filters on other fields fail. You
can also use a comparison operator in this query type.
-
Valid—you can filter solely on
EventDate, but single filters on other fields fail. You
can also use a comparison operator in this query
type.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate>=2014-11-27T14:54:16.000Z
-
Valid—you can filter solely on
EventDate, but single filters on other fields fail. You
can also use a comparison operator in this query
type.
-
Filtered on EventDate and UserId
-
Valid—when filtering on UserId, also
filter on EventDate and don’t use any operator other
than
equals.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and UserId='005D0000000nUP5IAM' -
Invalid—filtering only on UserId
produces an
error.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE UserId='005D0000000nUP5IAM' -
Invalid—using a comparison operator or date function that
uses a comparison operator on any field other than the last causes the query
to
fail.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate<=DATETIMEVALUE(TODAY()) and UserId='005D0000000nUP5IAM'
-
Valid—when filtering on UserId, also
filter on EventDate and don’t use any operator other
than
equals.
-
Filtered on EventDate, UserId, and
EntryPointId
-
Valid—to filter on EntryPointId, you
must first filter on EventDate and
UserId.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and UserId='005D0000000nUP5IAM' and EntryPointId='01pR00000004HM9IAM' -
Invalid—filtering only on the
EntryPointId field or on the
EntryPointId filed and one other field isn’t
supported.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and EntryPointId='01pR00000004HM9IAM' -
Invalid—the order of the fields you’re filtering on matters
as well. If the fields in your WHERE
clause aren’t in the correct order, your query will
fail.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EntryPointId='' and UserId='005D0000000nUP5IAM' and EventDate=2014-11-27T14:54:16.000Z
-
Valid—to filter on EntryPointId, you
must first filter on EventDate and
UserId.
-
Filtered on EventDate, UserId,
EntryPointId, and
EntryPointType
-
Valid—filtering on EntryPointType only
works if you’re also filtering over EventDate,
UserId, and
EntryPointType.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and UserId='005D0000000nUP5IAM' and EntryPointId='01pR00000004HM9IAM' and EntryPointType='ApexClass' -
Invalid—if you don’t filter on all the required fields,
filtering over EntryPointType
fails.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and UserId='005D0000000nUP5IAM' and EntryPointType='ApexClass'
-
Valid—filtering on EntryPointType only
works if you’re also filtering over EventDate,
UserId, and
EntryPointType.
-
Filtered on EventDate, UserId,
EntryPointId, EntryPointType, and
Id
-
Valid—you can filter over the Id field
only if you filter over all the four other valid fields as
well.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EventDate=2014-11-27T14:54:16.000Z and UserId='005D0000000nUP5IAM' and EntryPointId='01pR00000004HM9IAM' and EntryPointType='ApexClass' and Id='1HDR00000004C93OAE' -
Invalid—if you fail to include one or more of the fields
preceding Id in the WHERE clause, the query
fails.
1SELECT EntryPointId, EntryPointName, EventDate, LimitType, Username 2FROM ApexLimitEvent 3WHERE EntryPointId='01pR00000004HM9IAM' and EntryPointType='ApexClass' and Id='1HDR00000004C93OAE'
-
Valid—you can filter over the Id field
only if you filter over all the four other valid fields as
well.