Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Slow fix-tree queries on RDS Postgres #6522
Hi DjangoCMS team! We recently upgraded our DjangoCMS site from 3.4.2 to 3.5.2 and ran into similar issues with very slow queries during the
Here's the whole long story:
We have about ~75k rows in the
We have a statement timeout set to kill long-running queries and this one was killed right away the first time we tried it in our staging environment.
Here's the query plan Postgres returned when I ran an
Note that those
After observing a few other queries, I noticed none of our LIKE queries seemed to be using indexes. After reading up on LIKE queries and indexes in the Postgres docs, I found the following in the locale documentation:
Sure enough, the locale on our RDS instance was set to
Changing our locale wasn't an option, but we did manage to speed up this query by adding the
First we enabled the extension:
...then added an index with a
This brought the query down to ~10s. Here's the query plan after adding the index:
I'm omitting "expected" and "actual" below—it would be great for this command to be as fast as possible, but I primarily wanted to write this up for other Postgres RDS users who may encounter a similar issue! I think this is an issue at the intersection of RDS, treebeard and DjangoCMS, and the best fix here might just be to document it.