简体   繁体   English

Class :: DBI-是否加载所有表?

[英]Class::DBI - does it load all tables?

We have a MySQL database with very big number of tables. 我们有一个包含大量表的MySQL数据库。 Unfortunately in 2018 we still use Perl CGI. 不幸的是,在2018年,我们仍然使用Perl CGI。 So loading time of a script is essential. 因此,脚本的加载时间至关重要。

DBIx::Class was ruled out by me because it loads about 1.6 sec (so long because it loads Perl definitions for all tables of the DB) what is clearly too much. 我排除了DBIx::Class ,因为它加载了大约1.6秒(之所以这么长,是因为它加载了数据库的所有表的Perl定义),这显然太多了。

How quickly Class::DBI loads? Class::DBI加载速度有多快? My main question: Does Perl load information about all available tables (like DBIx::Class does) when we use Class::DBI or does it load Perl definitions for only these tables which we actually use? 我的主要问题:当我们使用Class::DBI时,Perl是否加载有关所有可用表的信息(如DBIx::Class一样),还是仅为我们实际使用的这些表加载Perl定义?


The following is a DBIx::Class code which loads 1.6 sec: 以下是一个DBIx::Class代码,加载时间为1.6秒:

#!/usr/bin/perl

package MyApp::Schema;
use lib '.../ORMs/dbix-class';
use base qw/DBIx::Class::Schema/;

__PACKAGE__->load_namespaces();

1;

(The schema is autogenerated.) (该模式是自动生成的。)

Is there any way to make it faster? 有什么方法可以使其更快? How to use it without loading all tables? 如何在不加载所有表的情况下使用它?

I really wouldn't recommend Class::DBI . 我真的不推荐Class :: DBI It's been unmaintained for twelve years - and there were good reasons why everyone switched to DBIx::Class . 它已经十二年没有维护了-每个人都改用DBIx :: Class的理由很充分。

I would highly recommend working on the problem that leads to you still using CGI. 我强烈建议您解决导致您仍在使用CGI的问题。 What is preventing you from, for example, using CGI::Emulate::PSGI to trivially convert your CGI code to PSGI apps which you can then deploy in a persistent environment like FastCGI or, better, as a standalone service which you can then access using nginx? 是什么阻止您使用CGI :: Emulate :: PSGI将您的CGI代码简单地转换为PSGI应用程序,然后您可以将它们部署在FastCGI等持久性环境中,或者更好地作为独立服务进行部署,然后可以访问使用nginx? Any of these solutions would mean that the DBIx::Class load time is no longer problem. 这些解决方案中的任何一个都意味着DBIx :: Class加载时间不再是问题。

Obviously, I have no idea what is keeping you tied to CGI. 显然,我不知道是什么使您与CGI保持联系。 But, in my experience, moving to PSGI solution is often easier than people expect it to be and it will undoubtedly leave you in a better position. 但是,以我的经验,迁移到PSGI解决方案通常比人们期望的要容易,并且无疑将使您处于更好的位置。

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

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