Skip to content

Conversation

@akhil018
Copy link

@akhil018 akhil018 commented Dec 20, 2023

The problem was identified in the foreign key(parent_id) column, where retrieval and deletion of records took an unexpectedly long time. To optimize the retrieval and deletion process, this fix introduces a new index on the relevant foreign key (parent_id) column.

This commit addresses performance issues related to both record deletion and retrieval in the sqlalchemy_mptt library. Adding an index to the foreign key(parent_id) column improves the efficiency of both operations, significantly reducing the time taken for deletion and retrieval.

This commit addresses performance issues related to both record deletion and retrieval in the sqlalchemy_mptt library. Adding an index to the foreign key(parent_id) column improves the efficiency of both operations, significantly reducing the time taken for deletion and retrieval.
@fayazkhan
Copy link
Collaborator

@akhil018 could you help in attempting to write a corresponding test for this change?

ForeignKey(
"{}.{}".format(cls.__tablename__, pk.name), ondelete="CASCADE"
),
index=True
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @akhil018, which dialect is this patch for? Wouldn't the ForeignKey implicitly add the index as well?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants