Newer Version Available

This content describes an older version of this product. View Latest

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.

Supported Calls

query()

Fields

Field Details
EntryPointId
Type
reference
Properties
Filter, Nillable, Sort
Description
The ID of the entity that set off the Apex event. See EntryPointType.
EntryPointName
Type
string
Properties
Nillable
Description
The name of the Apex class, component, page, or trigger that set off the Apex event.
EntryPointType
Type
string
Properties
Filter, Nillable, Restricted picklist, Sort
Description
The type of entity that set off the event. Possible values include:
  • ApexClass
  • ApexComponent
  • ApexPage
  • ApexTrigger
EventDate
Type
dateTime
Properties
Filter, Nillable, Sort
Description
The time of the specified event. For example, 2013-01-01T03:01:01Z. Seconds are the most granular setting.
ExecutionIdentifier
Type
string
Properties
Nillable
Description
Identifies each Apex limit event associated with a particular code execution. For example, if one Apex class triggers four Apex limit events, all four events have the same value for ExecutionIdentifier.
LimitType
Type
string
Properties
Nillable, Restricted picklist
Description
The Apex governor limit that was exceeded. Possible values are:
  • DATABASE_TIME: Database time
  • HEAP_CHECK_INTERVAL: Heap check interval
  • MAX_CPU_MILLISECONDS: Maximum CPU time (in ms)
  • MAX_HEAP_SIZE: Maximum heap size
  • CALLOUT: Number of callouts
  • DML_ROWS: Number of DML rows
  • DML: Number of DML statements
  • EMAIL_INVOCATIONS: Number of email invocations
  • FUTURE: Number of future calls
  • MOBILE_PUSHES: Number of Mobile Apex push calls
  • QUERY_LOCATOR_SOQL_ROWS: Number of query locator rows
  • SOQL_ROWS: Number of query rows
  • APEX_CURSOR_SOQL_ROWS: Number of query rows in an APEX cursor
  • QUEUEABLE: Number of queueable jobs added to the queue
  • AGGS: Number of SOQL aggregate queries
  • SOQL: Number of SOQL queries
  • SOSL: Number of SOSL queries
  • SOQL_BATCH_SIZE: Query batch size
LimitValue
Type
double
Properties
Nillable
Description
Represents the percentage of the maximum allowed limit value. For example, a value of 1.01 indicates that a transaction exceeded the limit by 1%. A value of 0.01 indicates that a transaction only consumed 1% of the limit.
NamespacePrefix
Type
string
Properties
Nillable
Description
The namespace prefix for the executed Apex class, component, or trigger. See Namespace Prefix.
UserId
Type
reference
Properties
Filter, Nillable, Sort
Description
The 18-character ID of the user who hit the Apex governor limit.
Username
Type
string
Properties
Nillable
Description
The username of the user who hit the Apex governor limit.

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.

Date functions such as convertTimeZone() aren’t supported—for example, SELECT CALENDAR_YEAR(EventDate), Count(Id) FROM LoginEvent GROUP BY CALENDAR_YEAR(EventDate) returns an error. You can use date literals in your queries and some date/time functions like TODAY(), YESTERDAY(), and LAST_n_DAYS:1. However, these functions use comparison operators behind the scenes. Therefore, you can use them only in the final expression of the WHERE clause.

Note

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.
  • 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.
  • Filtered on EventDate and UserId
    • Valid—when filtering on UserId, also filter on EventDate and don’t use any operator other than equals.
    • Invalid—filtering only on UserId produces an error.
    • 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.
  • Filtered on EventDate, UserId, and EntryPointId
    • Valid—to filter on EntryPointId, you must first filter on EventDate and UserId.
    • Invalid—filtering only on the EntryPointId field or on the EntryPointId filed and one other field isn’t supported.
    • 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.
  • Filtered on EventDate, UserId, EntryPointId, and EntryPointType
    • Valid—filtering on EntryPointType only works if you’re also filtering over EventDate, UserId, and EntryPointType.
    • Invalid—if you don’t filter on all the required fields, filtering over EntryPointType fails.
  • 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.
    • Invalid—if you fail to include one or more of the fields preceding Id in the WHERE clause, the query fails.