Skip to content
No description, website, or topics provided.
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib/ecto
test
.coveralls.yml
.formatter.exs
.gitignore
.tool-versions
.travis.yml
CHANGELOG.md
LICENSE
README.md
mix.exs
mix.lock

README.md

Build Status Hex.pm License: MIT Coverage Status

Explain

Adds explain function to Ecto.Repo

Usage

To include the explain function in repos, just add use Ecto.Explain to your repo. After that, the function explain/1 will be available for you.

# repo.ex
defmodule Ecto.ExplainTest.Repo do
  use Ecto.Repo, 
    otp_app: :my_project, 
    adapter: Ecto.Adapters.Postgres
  use Ecto.Explain
end
# posts.ex
Repo.explain(from(p in Post))

Update on posts p0  (cost=0.00..10.70 rows=70 width=1046)
  ->  Seq Scan on posts p0  (cost=0.00..10.70 rows=70 width=1046)
Repo.explain(from(posts in Post), format: :json, analyze: true)

[
  [
    {
      "Execution Time": 0.084,
      "Plan": {
        "Actual Loops": 1,
        "Actual Rows": 0,
        "Actual Startup Time": 0.027,
        "Actual Total Time": 0.027,
        "Alias": "p0",
        "Node Type": "Seq Scan",
        "Parallel Aware": false,
        "Plan Rows": 70,
        "Plan Width": 1040,
        "Relation Name": "posts",
        "Startup Cost": 0.0,
        "Total Cost": 10.7
      },
      "Planning Time": 0.585,
      "Triggers": []
    }
  ]
]

Installation

If available in Hex, the package can be installed by adding ecto_explain to your list of dependencies in mix.exs:

def deps do
  [
    {:ecto_explain, "~> 0.1.2"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ecto_explain.

You can’t perform that action at this time.