SELECT typarray FROM pg_type WHERE typname = 'citext'

SELECT typarray FROM pg_type WHERE typname = 'citext'

SELECT typarray FROM pg_type WHERE typname = 'citext'

为什么我在 Django 调试面板中收到此查询,这是什么意思?每当我导航到新页面时,此查询都会将 运行 作为第一个,然后是所有其他查询,在 python shell 中使用 connection.queries 命令也是如此。我正在使用 django 1.11 和 postgres 9.6。

citex is a PostgreSQL extension and has no fixed typarray so the following query needs to be executed to query pg_type 在 Django 端使用 psycopg2 注册扩展

为什么你每次加载页面时都会看到这个查询被执行是因为它没有在内部缓存,这似乎是为 Django 2.0 排序的

另请注意,1.11 之前的 Django 版本不会调用以下查询,因为 citext 在 Django 1.11 左右的版本中实现。