[英]Creating an index on an SQLite db using DBIx::Class
I'm beginning to think that my DBIx::Class tables need indices - I have a few expensive queries over multiple joins and I'd like to see if I can optimise them a bit. 我开始认为我的DBIx :: Class表需要索引-我在多个联接上有一些昂贵的查询,我想看看是否可以对其进行一些优化。 Is there a way to create and maintain indices on tables within DBIx::Class?
有没有一种方法可以在DBIx :: Class内的表上创建和维护索引?
The fine manual says to create an sqlt_deploy_hook
function and use add_index
to create the index; 好的手册说要创建一个
sqlt_deploy_hook
函数,并使用add_index
创建索引。 for example: 例如:
package My::Schema::Result::Artist;
__PACKAGE__->table('artist');
__PACKAGE__->add_columns(id => { ... }, name => { ... })
sub sqlt_deploy_hook {
my ($self, $sqlt_table) = @_;
$sqlt_table->add_index(name => 'idx_name', fields => ['name']);
}
1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.