EctoNPlusOne.Detection (EctoNPlusOne v0.1.0)

Copy Markdown View Source

Information about a potential N+1 query passed to the configured :on_detect callback.

A detection represents one parameterized query shape after it crosses the configured execution and parameter-variant thresholds.

The fields are:

  • :query - the parameterized SQL string with surrounding whitespace removed
  • :repo and :source - the Repo and Ecto source that emitted the query
  • :operation - the classified SQL operation
  • :count - executions observed in the active window when detection occurred
  • :parameter_variants - distinct parameter signatures observed
  • :params - retained parameter samples, empty unless :include_params is enabled
  • :callsite - the nearest frame under a configured application module
  • :stacktrace - every matching application frame used to group the query
  • :total_time - accumulated Ecto :total_time in native time units

Summary

Types

t()

A potential N+1 query detected from Ecto telemetry events.

Types

operation()

@type operation() :: :select | :insert | :update | :delete | :transaction | :other

t()

@type t() :: %EctoNPlusOne.Detection{
  callsite: Exception.stacktrace_entry(),
  count: pos_integer(),
  operation: operation(),
  parameter_variants: pos_integer(),
  params: [term()],
  query: String.t(),
  repo: module(),
  source: term(),
  stacktrace: Exception.stacktrace(),
  total_time: non_neg_integer()
}

A potential N+1 query detected from Ecto telemetry events.