【发布时间】:2021-06-24 15:57:24
【问题描述】:
我在 Django 中使用 Postgres,我想获取我在表上创建的索引的信息,特别是我想查看索引的大小。
【问题讨论】:
标签: django postgresql orm django-orm
我在 Django 中使用 Postgres,我想获取我在表上创建的索引的信息,特别是我想查看索引的大小。
【问题讨论】:
标签: django postgresql orm django-orm
如果您可以在 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()
【讨论】: