DEV Community

loading...

Elixir Wizards Talk: "Dealing With a Monster Ecto Query"

Mackenzie
I'm a tech generalist. I've done desktop Linux app work, systems work, and web dev stuff (in Django, Rails, and Phoenix). I got into functional programming & Elixir last year, and I really like it.
Originally published at mackenzie.morgan.name ・1 min read

Last month, I spoke at the first-ever Elixir Wizards Conference. It was a lightning talk walking through a refactor I did before the 2020 US Presidential Election, titled "Dealing With a Monster Ecto Query."

I work for a news company, so the presidential election is a huge deal; we can't have downtime. I knew which query was our bottleneck, so I optimized it right before the election. This took advantage of a few Elixir features, like atoms, the pin operator, and concurrency primitives.

You can watch the talk below:

Source code for slides

Discussion (3)

Collapse
dkuku profile image
Daniel Kukula • Edited

Hi @maco , great example but is there any chance that you can compare your approach with having the 4 separate queries connected with union or union_all instead sending 4 queries? hexdocs.pm/ecto/Ecto.Query-macro-u...

Collapse
tfantina profile image
Travis Fantina

Wow, "Elixir Wizards" is a great name for an Elixir conference. I will give this a watch when I have some downtime.

Collapse
maco profile image
Mackenzie Author

Elixir Wizards is actually a podcast originally, and they decided to start a conference.