# Ecto\_sqlite different read and write pools

**URL:** <https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588>\
**Category:** Questions\
**Tags:** sqlite3, ecto\_sql\
**Created:** [May 16, 2024, 7:33am UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588 "2024-05-16T07:33:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcoopman](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tcoopman/32/8112_2.png) [@tcoopman](https://forum.elixirforum.com/u/tcoopman)\
**Post date:** [May 16, 2024, 7:33am UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588/1 "2024-05-16T07:33:51Z")

</div>

Context: I want to apply some of the recommendations specified in this article [Optimizing SQLite for servers](https://kerkour.com/sqlite-for-servers)

Specifically: 1 Write connection, multiple Read connections

My thought on how to solve this was to use 2 different ecto repos, one for writes, one for reads and give the read repo a `pool_size` of 1 and the read a different, bigger `pool_size`.

That seems to work ok, but I run into a problem with testing and the ecto sandbox.  
Because ofcourse there are now 2 sandboxes and the read repo can’t read what the write repo wrote.

Here are my thoughts on how to solve this:

1. don’t use 2 different repo’s and accept that I can’t do what the article suggests
2. maybe there is an other way with 1 repo that allows me to set different read and write pools
3. fix the tests by removing the sandbox and cleaning up the db manually after each test - ecto\_sqlite3 doesn’t allow async tests anyway, so this would not be to much of an issue
4. …?

Does anyone have any suggestion?

---

<div class="post-metadata">

**Author:** ![LostKobrakai](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/32/3072_2.png) [@LostKobrakai](https://forum.elixirforum.com/u/LostKobrakai)\
**Post date:** [May 16, 2024, 10:09am UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588/2 "2024-05-16T10:09:19Z")

</div>

1. Wait for [Replace DirtyNIF execution model with a different mechanism · Issue #192 · elixir-sqlite/exqlite · GitHub](https://github.com/elixir-sqlite/exqlite/issues/192) to be resolved

---

<div class="post-metadata">

**Author:** ![joey\_the\_snake](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joey\_the\_snake](https://forum.elixirforum.com/u/joey_the_snake)\
**Post date:** [May 16, 2024, 11:53am UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588/3 "2024-05-16T11:53:52Z")

</div>

I would do number 3

---

<div class="post-metadata">

**Author:** ![dimitarvp](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/32/38664_2.png) [@dimitarvp](https://forum.elixirforum.com/u/dimitarvp)\
**Post date:** [May 16, 2024, 12:16pm UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588/4 "2024-05-16T12:16:21Z")

</div>

Either 3 or what @LostKobrakai’s idea.

---

<div class="post-metadata">

**Author:** ![tcoopman](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tcoopman/32/8112_2.png) [@tcoopman](https://forum.elixirforum.com/u/tcoopman)\
**Post date:** [May 17, 2024, 11:01am UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588/5 "2024-05-17T11:01:35Z")

</div>

Thanks all, going to read into that issue, but it looks like it might be out a while, so will look into 3 as well.

Does anyone see downsides for 3?  
Or downsides for using 2 repos in general?

---

<div class="post-metadata">

**Author:** ![D4no0](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/d4no0/32/33624_2.png) [@D4no0](https://forum.elixirforum.com/u/D4no0)\
**Post date:** [May 17, 2024, 11:22am UTC](https://forum.elixirforum.com/t/ecto-sqlite-different-read-and-write-pools/63588/6 "2024-05-17T11:22:03Z")

</div>

No issues besides the potential error prone behavior of doing this manually, well at least as long as you don’t try to write from both repos.
