cockroachdb / cockroachdb/django-cockroachdb

Cannot create database index on foreignkey field

Open
#293 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
174
Forks
31
PR merge metrics
No merged PRs in 30d

Description

I'm experiencing the same problem described in this blog post: https://mathieulamiot.com/my-feedbacks-on-using-cockroachdb-for-a-data-intensive-django-service/

Basically, creating a foreignkey field does not create a database index, even if ``db_index=True`` is specified. The workaround described above is to make a RunSQL migration to manually create the index for every field, but it would be better to respect the db_index argument.

I am using cockroachdb 22.1.22 and django-cockroachdb==3.2.2.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the linked CockroachDB/Django blog post and reproduce the reported behavior with CockroachDB 22.1.22, django-cockroachdb 3.2.2, and a Django ForeignKey using db_index=True. Compare the resulting schema with the manual RunSQL workaround; done means the expected foreign-key index is created without that workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.