# Postgres recursive CTE on single table

**URL:** <https://forum.elixirforum.com/t/postgres-recursive-cte-on-single-table/21730>\
**Category:** Questions\
**Tags:** sql, postgres, postgresql, ecto-query\
**Created:** [April 18, 2019, 12:52pm UTC](https://forum.elixirforum.com/t/postgres-recursive-cte-on-single-table/21730 "2019-04-18T12:52:24Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MarioFlach](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/marioflach/32/24564_2.png) [@MarioFlach](https://forum.elixirforum.com/u/MarioFlach)\
**Post date:** [April 18, 2019, 10:37pm UTC](https://forum.elixirforum.com/t/postgres-recursive-cte-on-single-table/21730/7 "2019-04-18T22:37:56Z")

</div>

Or is it even better to write an `IMMUTABLE FUNCTION`?

My `git_commit` table is _append-only_ as Git objects are never changed. The function will always return the same ancestor tree for a specific `oid`.

---

_[View the full topic](https://forum.elixirforum.com/t/postgres-recursive-cte-on-single-table/21730)._
