Class :: DBI-是否加载所有表格? [英] Class::DBI - does it load all tables?

查看:90
本文介绍了Class :: DBI-是否加载所有表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含大量表的MySQL数据库.不幸的是,在2018年,我们仍然使用Perl CGI.因此,脚本的加载时间至关重要.

We have a MySQL database with very big number of tables. Unfortunately in 2018 we still use Perl CGI. So loading time of a script is essential.

DBIx::Class被我排除了,因为它加载了大约1.6秒(之所以如此,是因为它加载了数据库的 all 表的Perl定义),显然是太多了.

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.

Class::DBI加载有多快?我的主要问题:使用Class::DBI时,Perl是否加载有关所有可用表的信息(如DBIx::Class一样),还是仅为我们实际使用的这些表加载Perl定义?

How quickly Class::DBI loads? 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?

以下是DBIx::Class代码,其加载时间为1.6秒:

The following is a DBIx::Class code which loads 1.6 sec:

#!/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?

推荐答案

我真的不推荐类别:: DBI .它已经维护了十二年了-有充分的理由为什么每个人都切换到 DBIx :: Class DBIx :: Class .

I really wouldn't recommend Class::DBI. It's been unmaintained for twelve years - and there were good reasons why everyone switched to DBIx::Class.

我强烈建议您解决导致您仍在使用CGI的问题.是什么使您无法使用例如 CGI :: Emulate :: PSGI 轻松地将CGI代码转换为PSGI应用程序,然后将它们部署在FastCGI等持久性环境中,或者更好地作为独立服务进行部署,然后可以使用nginx进行访问?这些解决方案中的任何一个都意味着DBIx :: Class加载时间不再是问题.

I would highly recommend working on the problem that leads to you still using 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? Any of these solutions would mean that the DBIx::Class load time is no longer problem.

很显然,我不知道是什么使您与CGI保持联系.但是,以我的经验,迁移到PSGI解决方案通常比人们期望的要容易,而且无疑会让您处于更好的位置.

Obviously, I have no idea what is keeping you tied to 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.

这篇关于Class :: DBI-是否加载所有表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆