【问题标题】:Get index info in postgres using Django ORM使用 Django ORM 在 postgres 中获取索引信息
【发布时间】:2021-06-24 15:57:24
【问题描述】:

我在 Django 中使用 Postgres,我想获取我在表上创建的索引的信息,特别是我想查看索引的大小。

【问题讨论】:

    标签: django postgresql orm django-orm


    【解决方案1】:

    如果您可以在 SQL 上执行此操作,那么您可以使用游标执行此操作: https://docs.djangoproject.com/en/3.1/topics/db/sql/#executing-custom-sql-directly

    with connection.cursor() as cursor:
        cursor.execute("SELECT pg_size_pretty (pg_indexes_size('mytable'));")
        row = cursor.fetchone()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      相关资源
      最近更新 更多