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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:18:33+00:00 2026-06-08T13:18:33+00:00

I have inherited a legacy application which makes use of a self-referencing table to

  • 0

I have inherited a legacy application which makes use of a self-referencing table to facilitate a hierarchical structure. This results in recursive method calls which are creating a “bad smell”.

The parent_id column references the primary key of the same table, and there are roughly 25 million records here:

+-------------+---------+------+-----+---------+----------------+
| Field       | Type    | Null | Key | Default | Extra          |
+-------------+---------+------+-----+---------+----------------+
| phase_id    | int(10) | NO   | PRI | NULL    | auto_increment |
| plat_id     | int(10) | YES  | MUL | NULL    |                |
| name        | text    | YES  |     | NULL    |                |
| parent_id   | int(10) | YES  | MUL | NULL    |                |
| plan_id     | int(10) | YES  | MUL | NULL    |                |
+-------------+---------+------+-----+---------+----------------+

mysql> show table status like 'ref'\G
*************************** 1. row ***************************
Name: phase
Engine: MyISAM
Version: 10
Row_format: Dynamic
Rows: 25223658
Avg_row_length: 20
Data_length: 509450960
Max_data_length: 281474976710655
Index_length: 1026267136
Data_free: 0
Auto_increment: 25238013

I have a few questions about this kind of structure:

  • Is it generally bad practice to implement a self-referencing table? The main negative I can think of is that it is difficult/impossible to get the maximum depth of the hierarchy in a single query as there may be an X number children.
  • Is it worth redesigning this? Having so much data makes it more difficult to move it around.
  • What are my options? I have heard a little bit about table partitioning, but don’t know if it is suitable in my scenario.

Any pointers would be really appreciated
ns

  • 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-08T13:18:34+00:00Added an answer on June 8, 2026 at 1:18 pm

    We ended up scrapping the existing self-referencing table. And created a new table to house a more simple model.

    Thanks to Sebas for the Link above. There is a lot of goodness in there!

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

Sidebar

Related Questions

We have inherited an application (Java-based, running on WebLogic 10.3.5) that makes extensive use
We've inherited large legacy application which is structured roughly like this: class Application {
I have a legacy application that I inherited that passes a lot of XML
I have inherited couple of .Net (C#) application which does not have any tracing
I have inherited an application that logs the results of certain daily commands that
We have an ASP Classic legacy web application , which is hosted in Windows
I have inherited some legacy HTML in which it has the following elements in
I have inherited some legacy code which generates a ton of inline styles. The
I currently am working on a legacy application and have inherited some shady SQL
I have inherited some legacy vb6 code. It's a tool which generates a local

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.