Skip to content

Conversation

@humitos
Copy link
Member

@humitos humitos commented Jan 21, 2026

I hit a limitation in PostgreSQL with the length of indexed fields.

OperationalError: index row size 6104 exceeds btree version 4 maximum 2704 for index "builds_buildconfig_data_key"
DETAIL:  Index row references tuple (4760,2) in relation "builds_buildconfig".
HINT:  Values larger than 1/3 of a buffer page cannot be indexed.
Consider a function index of an MD5 hash of the value, or use full text indexing.

I found others users hitting the same issue and I ended up with this mixed solution between what AI suggested me and what I found online.

I'm not 100% happy with it, but I don't have a better idea right now.

I hit a limitation in PostgreSQL with the length of indexed fields.

```
OperationalError: index row size 6104 exceeds btree version 4 maximum 2704 for index "builds_buildconfig_data_key"
DETAIL:  Index row references tuple (4760,2) in relation "builds_buildconfig".
HINT:  Values larger than 1/3 of a buffer page cannot be indexed.
Consider a function index of an MD5 hash of the value, or use full text indexing.
```

I found others users hitting the same issue and I ended up with this
mixed solution between what AI suggested me and what I found online.

I'm not 100% happy with it, but I don't have a better idea right now.
@humitos
Copy link
Member Author

humitos commented Jan 21, 2026

A different approach to a solution would be to just handle this exception at https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/builds/models.py#L878 and skip saving the config into the database for this cases. It doesn't seem to be common. I only found ~10 cases in 3.5M Build objects so far.

@stsewd
Copy link
Member

stsewd commented Jan 21, 2026

This was one of my worries about this new method. I'm +1 on using a hash, that should reduce the size of the index as well.

Comment on lines +16 to +20
migrations.AddField(
model_name="buildconfig",
name="data_hash",
field=models.CharField(editable=False, max_length=64, null=True, unique=True),
),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to create a data migration for all these objects to calculate this hash and save it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants