#33017: Fix get_storage_engine to only look at current database
-------------------------------------+-------------------------------------
               Reporter:  Matjaz     |          Owner:  nobody
  Gregoric                           |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  MySQL
           Triage Stage:             |      Has patch:  1
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.770a3a65843ec91714e3b738b8336cb7%40djangoproject.com.

Reply via email to