microsoft/mssql-django

[BUG] - Degradation caused by DatabaseIntrospection.get_table_list

royabend opened this issue · 3 comments

Software versions

  • Django: 3.2.25
  • mssql-django: 1.4
  • python: 3.9.18
  • SQL Server: Microsoft.Sql/servers version 12.0
  • OS: Linux amd64

Problem description and steps to reproduce
In your recent PR, a change was made to the query within DatabaseIntrospection.get_table_list, introducing complexity such as JOINs to support database comments. This modification has resulted in a significant increase in CPU usage, particularly noticeable on large database schemas. Upon investigation, it was found that the complex query is causing our database to consistently utilize over 90% CPU, leading to performance degradation.

Given that DatabaseIntrospection.get_table_list is utilized extensively within Django's source code, avoiding its usage isn't feasible. Therefore, I propose adding an option to exclude database comments retrieval, potentially by checking DatabaseFeatures.supports_comments within the get_table_list method. This would provide a solution for mitigating the performance impact caused by the complex query.

Thank you for considering this enhancement.

Thanks for raising this. Will look into this further

Thanks! Is there an estimation for the fix release?

we just released this in version 1.5