简体   繁体   English

如何使用DBIx :: Class在PostGIS几何列上创建GiST索引?

[英]How do I create a GiST index on a PostGIS geometry column using DBIx::Class?

I have a Postgres + PostGIS database with geometry columns. 我有一个带有几何列的Postgres + PostGIS数据库。

I would like to add indices to them, eg 我想为其添加索引,例如

create index plot_idx_location on plot using gist (location);

I know how to create indices in DBIx::Class using the sqlt_deploy_hook method, but I am unsure what the syntax for add_index is to generate the above statement. 我知道如何使用sqlt_deploy_hook方法在DBIx :: Class中创建索引,但是我不确定add_index的语法是如何生成上述语句的。

Reading the SQL::Translator documentation ( http://search.cpan.org/~frew/SQL-Translator-0.11016/lib/SQL/Translator/Schema/Index.pm ) seems to be of no help. 阅读SQL :: Translator文档( http://search.cpan.org/~frew/SQL-Translator-0.11016/lib/SQL/Translator/Schema/Index.pm )似乎没有帮助。 There's no examples on using the "options" parameter, and breifly looking at the source code, I suspect it's not even supported. 没有使用“ options”参数的示例,只是简单地查看源代码,我怀疑它甚至不受支持。

So is there a way to do this, or do I need to hardcode the SQL statement in the sqlt_deploy_hook method instead? 那么有没有办法做到这一点,或者我需要在sqlt_deploy_hook方法中对SQL语句进行硬编码吗?

DBIx::Class itself doesn't generate DDL queries, SQL::Translator does. DBIx :: Class本身不会生成DDL查询,而SQL :: Translator会生成。 You have to generate such special indexes yourself, for example in an after 'deploy' method modifier in your schema class or with the deployment_statements methods. 您必须自己生成此类特殊索引,例如,在架构类中的after'deploy'方法修饰符中,或与deploy_statements方法一起生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM