# Ecto usage patterns

**URL:** <https://forum.elixirforum.com/t/ecto-usage-patterns/34234>\
**Category:** Discussions\
**Tags:** ecto, database, dsl\
**Created:** [September 8, 2020, 7:56am UTC](https://forum.elixirforum.com/t/ecto-usage-patterns/34234 "2020-09-08T07:56:02Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![edisonywh](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/edisonywh/32/14709_2.png) [@edisonywh](https://forum.elixirforum.com/u/edisonywh)\
**Post date:** [September 8, 2020, 8:17am UTC](https://forum.elixirforum.com/t/ecto-usage-patterns/34234/4 "2020-09-08T08:17:20Z")

</div>

Don’t think it has anything to do with “Ecto efficiency”.

Automatically preloading association was one of the biggest source of performance issues in Rails with N+1 queries, I am really glad that Ecto does not do that by default, it forces you to understand what exactly your code needs (I love when libraries nudges you to good, explicit/obvious patterns).

Anyway, I do like `User.find_by(email: "email")` style of code (which you can also use `Repo.get_by()` btw, but I was missing it for context functions, so I created a small library here [GitHub - edisonywh/condiment: 🍡 Add flavors to your context function without the hassles. · GitHub](https://github.com/edisonywh/condiment) that helps make this easier.

EDIT: Like nobbz pointed out as well, you can define a `.iex.exs` file, on the app level or on the global level, and that saves you a lot of typing too.

---

_[View the full topic](https://forum.elixirforum.com/t/ecto-usage-patterns/34234)._
