#34874: Add table_exists() to optimize checks for django_migrations table.
-------------------------------------+-------------------------------------
     Reporter:  pinaraf              |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 > For instance on a PG database with 8800 relations, the query takes 21ms.

 As far as I'm aware, tables introspection is extremely fast on PostgreSQL.
 This is proven by 21ms for 8800 tables.

 > Fixing the migrations recorder to keep the information cached would be a
 quick work around this, but it would still execute the long query at least
 once, but especially with django-tenant-schema it would end up taking tens
 of seconds (at least one call per tenant).

 This is cached in Django 5.0+ (ea8cbca579cc6742e119747fc1eb6ecf90638bce.)

 > I suggest adding an `table_exists(table_name)` function in
 `db.introspection`. Its base implementation could be simply a return
 table_name in self.table_names(), but specific DB engines like PostgreSQL
 could have an optimized variant.

 I don't think it's worth adding for a single (already cached) call.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34874#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/0107018ad6faecf5-d04bf406-4597-4ad9-9a4b-54a99d625755-000000%40eu-central-1.amazonses.com.

Reply via email to