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 8286959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:54:45+00:00 2026-06-08T11:54:45+00:00

I have an mysql db, and the data tables named according to the sharding

  • 0

I have an mysql db, and the data tables named according to the sharding rule, which means the name has a same prefix,e.g: the_table_,and has a number for suffix, so the table name will be the_table_1,the_table_2,the_table_3.When we want to select a row, we have to find the table suffix from sql select mod(primary_key_id, 64)+1, the sharding rule, and the 64 is a base number, which means we have 64 tables.

Now we want to use Solr to index the data in the tables,but solr data-config.xml can not support sql query with dynamic name,So is there any suggestion to fix this problem?

Things like this?

<entity name="audit" 
        query="select id,monitor_type,city,STATUS,is_history,timeout,author,author_uid,author_ip,operator_uid,operator,created_at,description from `main_table`">
        <field column="ID" name="id" />
        <field column="MONITOR_TYPE" name="monitor_type" />
        <field column="CITY" name="city" />
        <field column="STATUS" name="status" />
        <field column="IS_HISTORY" name="is_history" />
        <field column="AUTHOR" name="author" />
        <field column="AUTHOR_UID" name="author_uid" />
        <field column="AUTHOR_IP" name="author_ip" />
        <field column="OPERATOR_UID" name="operator_uid" />
        <field column="OPERATOR" name="operator" />

        <entity name="distribution" query="select mod(${audit.ID}, 256)+1 as table_id">
          <entity name="details" query="select content from detail${distribution.table_id} where id=${audit.ID}">
            <field column="CONTENT" name="content" />
          </entity>
        </entity>
</entity>

  • 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-08T11:54:46+00:00Added an answer on June 8, 2026 at 11:54 am

    I would create a stored procedure to do what you want and then call it from Solr. Something like this

    CREATE PROCEDURE `GetAuditDetails`(IN auditID INT)
    BEGIN
      DECLARE tableID INT DEFAULT 0;
      DECLARE sqlString VARCHAR(100) DEFAULT '';
      SELECT MOD(auditID, 256)+1 INTO tableID;
      SET @sqlString = CONCAT('select content from detail', tableID, ' where id=', auditID );
      PREPARE stmt FROM @sqlString;
      EXECUTE stmt;
    END;
    
    <entity name="audit" 
        query="select id,monitor_type,city,STATUS,is_history,timeout,author,author_uid,author_ip,operator_uid,operator,created_at,description from `main_table`">
            <field column="ID" name="id" />
            <field column="MONITOR_TYPE" name="monitor_type" />
            <field column="CITY" name="city" />
            <field column="STATUS" name="status" />
            <field column="IS_HISTORY" name="is_history" />
            <field column="AUTHOR" name="author" />
            <field column="AUTHOR_UID" name="author_uid" />
            <field column="AUTHOR_IP" name="author_ip" />
            <field column="OPERATOR_UID" name="operator_uid" />
            <field column="OPERATOR" name="operator" />
    
            <entity name="details" query="CALL GetAuditDetails(${audit.ID})">
               <field column="CONTENT" name="content" />
            </entity>
    </entity>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables named t1 and t2, which content list as following: mysql>
I have a mysql table which holds lots of data across multiple tables. So
I have a MySQL query that: gets data from three tables linked by unique
I have a .sql file from a MySQL dump containing tables, definitions and data
I have a mysql table field set as time type which stores data in
I have two MySQL tables named 'nodes' and 'joinTable' like shown below. I need
I have two MySQL tables describing data that can be extended into subclasses, one
please I have the same problem as I found here MySQL - Selecting data
I have data stored in a MySQL database according to the Entity-Attribute-Value pattern (EAV),
I have a MySQL table with the following data (simplified): INSERT INTO `stores` (`storeId`,

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.