#33017: Fix get_storage_engine to only look at current database
-------------------------------------+-------------------------------------
Reporter: Matjaz Gregoric | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: MySQL | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Matjaz Gregoric:
Old description:
> When querying the information_schema.tables for the storage engine, we
> have to specify table_schema in addition to table_name, otherwise the
> query returns a list of results for all tables with the specified name
> from every database in the system. If there are multiple tables with the
> same name but using different storage engines present in different
> databases in the MySQL instance, the query could return a wrong result.
>
> We have to limit the query to the current database to make sure we get
> the correct result.
>
> This also improves performance on MySQL instances with a large number of
> databases, since querying the information_schema table can be very slow.
>
> The get_storage_engine function that this patch fixes is invoked when
> adding columns during migrations to determine whether it should index the
> column. We have a MySQL instance with over a thousand databases in
> production and this patch has cut down the time it takes to run a
> specific set of django migrations from 2 hours to around 15 minutes.
New description:
https://github.com/django/django/pull/14766
When querying the information_schema.tables for the storage engine, we
have to specify table_schema in addition to table_name, otherwise the
query returns a list of results for all tables with the specified name
from every database in the system. If there are multiple tables with the
same name but using different storage engines present in different
databases in the MySQL instance, the query could return a wrong result.
We have to limit the query to the current database to make sure we get the
correct result.
This also improves performance on MySQL instances with a large number of
databases, since querying the information_schema table can be very slow.
The get_storage_engine function that this patch fixes is invoked when
adding columns during migrations to determine whether it should index the
column. We have a MySQL instance with over a thousand databases in
production and this patch has cut down the time it takes to run a specific
set of django migrations from 2 hours to around 15 minutes.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33017#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.c5f9bacbd6876ac4d0b712ded65e9100%40djangoproject.com.