Djangonaut diaries, week 3 - Working on an ORM issue
Hi there! The PR from the previous week is currently being reviewed, with some great suggestions from one of the Django fellows, Jacob Walls. In the meantime I picked up one of the issues that were...

Source: DEV Community
Hi there! The PR from the previous week is currently being reviewed, with some great suggestions from one of the Django fellows, Jacob Walls. In the meantime I picked up one of the issues that were suggested by the navigator for this cohort, Akash, an ORM optimization issue titled "Unnecessary creation of index for ManyToManyField". In summary, when Django creates the migrations for a many-to-many "through" table, it's creates a database index which may be redundant. But before I get to fix the issue, let's dig a bit on what are database indexes, how the most common index for relational databases work (balanced trees, aka b-trees), what are many-to-many (m2m) relations and junction tables (also called through-tables), and finally how "unique" indexes for m2m tables work. Knowing the basics of all that, we will have the tools to work on a proper fix. There's no point try to fix something we don't really understand. If you have a solid grasp of btree indexes and just want to jump to the