# PostgreSQL and Open edX

**URL:** <https://discuss.openedx.org/t/postgresql-and-open-edx/6441>\
**Category:** Site Operators\
**Created:** [January 15, 2022, 7:49pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441 "2022-01-15T19:49:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/dave/32/263_2.png) [@dave](https://discuss.openedx.org/u/dave)\
**Post date:** [January 15, 2022, 7:49pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/1 "2022-01-15T19:49:17Z")

</div>

If you run Open edX on PostgreSQL (or have tried to), could you please write a bit about your experiences here? There have been recent discussions in areas like [full text search](https://discuss.openedx.org/t/deprecation-removal-depr-170-move-from-elasticsearch-to-opensearch/5844/9) or [specifying collation settings in fields](https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.CharField.db_collation) that could potentially couple us more tightly to MySQL. We can maintain abstractions to try to avoid that, but that comes at a cost, and I’m trying to understand to what extent PostgreSQL support is valuable to folks.

Full disclosure: My personal position for a while has been that Postgres is a better database both on its own merits and in terms of its support in Django–but that the benefits don’t outweigh the switching costs. Or at least, the work necessary to safely migrate everything is not more important than the dozens of other things we could do with that developer/ops time and effort.

That being said, I have no idea how many folks are actually running PostgreSQL in production already, how important it is for folks who want to run it, etc.

Thank you.

---

<div class="post-metadata">

**Author:** ![jill](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/jill/32/3188_2.png) [@jill](https://discuss.openedx.org/u/jill)\
**Post date:** [January 16, 2022, 1:44am UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/2 "2022-01-16T01:44:34Z")

</div>

We don’t have any clients that run Open edX on Postgres, but… it would be nice to leave that door open.

I dream of a world where we can run the stack with only a single relational database service (and without mongo… unrelated thread, but here’s links in case people want them, see [Store modulestore’s course indexes in Django/MySQL](https://github.com/openedx/edx-platform/pull/27565) and [Replace cs\_comments\_service with pluggable alternatives](https://discuss.openedx.org/t/discourse-integration-plugin-for-open-edx/508/26)). One of the working discussion plugins is Discourse, which requires Postgres, and it would be sp fantastic if one day we could run both Open edX and Discourse on the same sql db service.

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [January 16, 2022, 7:49pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/3 "2022-01-16T19:49:52Z")

</div>

> [@dave](#):
>
> Full disclosure: My personal position for a while has been that Postgres is a better database both on its own merits and in terms of its support in Django–but that the benefits don’t outweigh the switching costs. Or at least, the work necessary to safely migrate everything is not more important than the dozens of other things we could do with that developer/ops time and effort.

I just want to add my personal opinion on this:  
It’s also worth considering that the time and effort needed to support PostgreSQL is a **setup cost** meaning it occurs once, while the benefit of using PostgreSQL is **continuous**. So the tradeoff might be worth it from a long term perspective.

---

<div class="post-metadata">

**Author:** ![dave](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/dave/32/263_2.png) [@dave](https://discuss.openedx.org/u/dave)\
**Post date:** [January 18, 2022, 3:43pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/4 "2022-01-18T15:43:37Z")

</div>

> [@ghassan](#):
>
> It’s also worth considering that the time and effort needed to support PostgreSQL is a **setup cost** meaning it occurs once, while the benefit of using PostgreSQL is **continuous**. So the tradeoff might be worth it from a long term perspective.

I respectfully disagree with that. PostgreSQL would be a one-time setup cost if we could pull a trigger and migrate everyone over in a relatively short period of time. That’s how I would think of it this was a commercial codebase at my company. But I believe that as an open source project, we’d be supporting both databases simultaneously for multiple Open edX releases. We would only really be able to enjoy the benefits of Postgres when MySQL was completely dropped for a given service, and we could stop [distorting our schema](https://github.com/openedx/blockstore/blob/master/blockstore/apps/bundles/models.py#L18-L53) to appease it. Maybe it’s still worth it, but we’re probably looking at a years-long transition to ensure that we’re not leaving behind big chunks of the community.

I can see at least four paths:

1. Status quo: MySQL (+ MariaDB?) is official and well tested, but aim for PostgreSQL compatibility and accept patches to fix any issues.
2. Fully support both databases, by increasing our testing with PostgreSQL.
3. Lean into MySQL, by allowing more MySQL-specific features via libraries like [django-mysql](https://django-mysql.readthedocs.io/en/latest/index.html).
4. Lean into PostgreSQL, with an eye towards long term migration.

In addition, we could try to fund development efforts to improve Django’s support for MySQL, which would fit for approaches 1-3.

---

<div class="post-metadata">

**Author:** ![dave](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/dave/32/263_2.png) [@dave](https://discuss.openedx.org/u/dave)\
**Post date:** [January 19, 2022, 12:41am UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/5 "2022-01-19T00:41:28Z")

</div>

~~So it turns out that we added django-mysql as an edx-platform dependency [back in 2018](https://github.com/openedx/edx-platform/commit/bab6e3669c8e804bbf9cdcb60008d39f4c0b4ef6#diff-c78548ba0296575da7a0efc133523a50d78adf17af53f890b0efd2a771b006a2R49), so it’s extremely unlikely that PostgreSQL has worked for the LMS or Studio at all since that time.~~

Edit: After reading a little more, it looks like we use django-mysql just to use its [ListCharField](https://django-mysql.readthedocs.io/en/latest/model_fields/list_fields.html#django_mysql.models.ListCharField), which seems to just build on CharField, and shouldn’t lock out other databases (which makes sense, since the tests are backed with in-memory SQLite).

---

<div class="post-metadata">

**Author:** ![qasimgulzar](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/qasimgulzar/32/6319_2.png) [@qasimgulzar](https://discuss.openedx.org/u/qasimgulzar)\
**Post date:** [November 5, 2024, 9:48am UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/6 "2024-11-05T09:48:03Z")

</div>

As part of ongoing efforts to enhance Open edX compatibility with PostgreSQL, I have dedicated time to address and update migrations, ensuring they work seamlessly with both PostgreSQL and MySQL.

I have submitted the following pull requests to support this initiative:

1. [edx-when](https://github.com/openedx/edx-when/pull/282/files)

2. [edx-enterprise](https://github.com/openedx/edx-enterprise/pull/2281)

3. [xblock-lti-consumer](https://github.com/openedx/xblock-lti-consumer/pull/511)

4. [edx-platform](https://github.com/openedx/edx-platform/pull/35762)

---

<div class="post-metadata">

**Author:** ![dave](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/dave/32/263_2.png) [@dave](https://discuss.openedx.org/u/dave)\
**Post date:** [November 5, 2024, 2:58pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/7 "2024-11-05T14:58:18Z")

</div>

@qasimgulzar: I’m excited to see that someone is working on PostgreSQL support. But before we start merging this into the various repos it needs to go into, I’d like to understand your long term goals maintenance implications.

Many (most?) installations of Open edX will continue to run MySQL for a long time to come, possibly indefinitely. If you’re envisioning this as a first step towards an eventual forced migration from MySQL to PostgreSQL for the community at large, then I think we need to have a larger conversation before this goes any further.

If this is envisioned as supporting both database backends concurrently, then I’d like to understand the maintenance plan. I’m going to assume that part of this effort would take the form of a PostgreSQL plugin for Tutor. We’d probably also add postgres to our testing matrix in GitHub. But we’d still be in a place where the majority of Open edX sites, developers, and the standard release testing process would use MySQL for the foreseeable future.

Is Arbisoft willing to maintain that Tutor plugin and commit to testing with PostgreSQL for every release? Will you be actively using PostgreSQL in production on some of your own instances?

Thank you.

---

<div class="post-metadata">

**Author:** ![qasimgulzar](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/qasimgulzar/32/6319_2.png) [@qasimgulzar](https://discuss.openedx.org/u/qasimgulzar)\
**Post date:** [November 5, 2024, 4:09pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/8 "2024-11-05T16:09:16Z")

</div>

Hi @Dave,

It’s great to reconnect with you! These changes represent the initial steps in making the edx-platform fully compatible with both PostgreSQL and MySQL. In the coming weeks, I plan to introduce new GitHub Actions to support PostgreSQL tests in subsequent PRs.

While I am no longer with Arbisoft, I am contributing these enhancements as an individual contributor. My long-term goal is to take ownership of these updates to ensure their continued improvement.

Additionally, I am planning to author a Tutor plugin to facilitate PostgreSQL support.

---

<div class="post-metadata">

**Author:** ![dave](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/dave/32/263_2.png) [@dave](https://discuss.openedx.org/u/dave)\
**Post date:** [November 5, 2024, 10:01pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/9 "2024-11-05T22:01:58Z")

</div>

All right, that sounds good. I created [an issue in openedx-learning](https://github.com/openedx/openedx-learning/issues/255) describing what would need to be done to make that repo support PostgreSQL. I’ll start reviewing your PRs this week.

Thank you for taking this on. 😄

---

<div class="post-metadata">

**Author:** ![qasimgulzar](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/qasimgulzar/32/6319_2.png) [@qasimgulzar](https://discuss.openedx.org/u/qasimgulzar)\
**Post date:** [November 25, 2024, 3:02pm UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/10 "2024-11-25T15:02:03Z")

</div>

[Here](https://www.youtube.com/watch?v=HTssaVwn3dQ) - I have posted short demo.

---

<div class="post-metadata">

**Author:** ![AntonOfTheWoods](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/antonofthewoods/32/301_2.png) [@AntonOfTheWoods](https://discuss.openedx.org/u/AntonOfTheWoods)\
**Post date:** [September 16, 2025, 5:52am UTC](https://discuss.openedx.org/t/postgresql-and-open-edx/6441/11 "2025-09-16T05:52:05Z")

</div>

Looks like were at the finish line! [fix: migrations to make postgresql compatible. by qasimgulzar · Pull Request #35762 · openedx/edx-platform · GitHub](https://github.com/openedx/edx-platform/pull/35762) All tests and checks pass! We just need the Ok from the maintainer team! 🙂
