Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9230849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:55:11+00:00 2026-06-18T05:55:11+00:00

I have several (~100 and counting) MySQL tables with more than 50M entries each.

  • 0

I have several (~100 and counting) MySQL tables with more than 50M entries each. The thing is that all this tables have exactly the same structure and I would like to create a single result class for them in DBIx::class.
For example consider a bunch of tables of the following structure:

CREATE TABLE users_table_1 (
  name TINYTEXT,
  username TINYTEXT
);
CREATE TABLE users_table_2 (
  name TINYTEXT,
  username TINYTEXT
);
...

I would like to be able to do the following without having to create a result class for each one of the tables.

my $users_1_rs = $schema->resultset('User_table_1');
my $users_2_rs = $schema->resultset('User_table_2');
...

I am new to DBIx::Class and the only two possible solutions that I could come up with are:

  1. For each of the tables use something like DBIx::Class::DynamicSubclass to subclass from a base result class with all common functionality. The disadvantage is that this way I still need to write a class (although a small one) for every single one of my tables.
  2. Use DBIx::Class::Loader and create the classes automatically from the database itself. However, I don’t find this solution very elegant and robust for my needs.

Could someone point me to a more elegant solution for this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:55:12+00:00Added an answer on June 18, 2026 at 5:55 am

    There is probably a metaprogramming API within DBIx::Class for dynamically creating table classes.

    In lieu of delving into the (rather large DBIx::Class) docs here is an alternative example creating the classes in plain Perl metaprogramming:

    package MySchema;
    use strict;
    use warnings;
    use parent 'DBIx::Class::Schema';
    
    our @tables = map { 'users_table_' . $_ } 1..2;
    
    require DBIx::Class::Core;
    
    # build table classes for users_tables_*
    for my $table (@MySchema::tables) {
        my $t = "MySchema::$table";
        {
            no strict 'refs';
            @{$t . '::ISA'} = qw/DBIx::Class::Core/;
        }
        $t->table($table);
        $t->add_columns(qw/name username/);
    }
    
    __PACKAGE__->load_classes(@MySchema::tables);
    
    1;
    

    In my simple tests the above worked for me 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several boxes (more than 100) that will be created dynamically in different
I have several xml files that are formated this way: <ROOT> <OBJECT> <identity> <id>123</id>
We have several images in our app, some of which are less than 100
I have several tables that contain multipolygons. I need to find points within these
I have several large text text files that all have the same structure and
Say I have an array that looks like this: array(100) { [0]=> array(4) {
We have several different optimization algorithms that produce a different result for each run.
I'm plotting some functions that have several discontinuities. Each function is given as a
I have several tables/variables (sampled below): mytable = { ['100'] = { ['2']=0,['3']=0,['5']=0,['6']=0,['7']=0,['9']=0}, ['101']
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.