【发布时间】:2019-03-09 00:42:06
【问题描述】:
我正在尝试通过 Django 模型创建新表并索引 Postgres 中的列。表创建使用另一个表的设置,索引使用pg_trgm
我可以直接在 Postgres 上通过
CREATE TABLE my_table (like my_other_table);
并像插入数据
INSERT INTO my_table SELECT * FROM MY_OTHER_TABLE TABLESAMPLE BERNOULLI (5);
这会将 my_other_table 中 5% 的数据放入 my_table 中
然后我按列索引
CREATE INDEX mycolumn_trgm_idx ON my_table USING GIN (my_column gin_trgm_ops);
当我直接在 postgres 上执行这些操作时没有问题,但我不知道如何(或者是否可能)通过 django 迁移来做到这一点
【问题讨论】:
标签: django postgresql