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

  • Home
  • SEARCH
  • 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 4608032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:47:14+00:00 2026-05-22T00:47:14+00:00

I am a developer and I am facing an issue while managing table which

  • 0

I am a developer and I am facing an issue while managing table which has large amount of records.

I am executing a cron job to fill up data in primary table (Table A) which has 5-6 columns and approx 4,00,000 to 5,00,000 rows and then creating another table and data in this table would continue to increase over the time.

TABLE A contains the raw data and my output table is TABLE B

My cron script truncates data in Table B then inserts data using select query

TRUNCATE TABLE_B; 

INSERT INTO TABLE_B (field1, field2) 
SELECT DISTINCT(t1.field2), t2.field2 
FROM TABLE_A AS t1 
INNER JOIN TABLE_A t2 ON t2.field1=t1.field1 
WHERE t1.field2 <> t2.field2 
GROUP BY t1.field2, t2.field2 
ORDER BY COUNT(t1.field2) DESC; 

Above select query produces approx 1,50,000 to 2,00,000 rows

Now it takes too much time to populate TABLE B and meanwhile If my application tries to access TABLE B then select query fails

Explaining query results following:

'1','PRIMARY','T1','ALL','field1_index',NULL,NULL,NULL,'431743','Using temporary;Using filesort' 
'1','PRIMARY','T2','ref','field1_index','field1_index','767','DBNAME.T1.field1','1','Using where' 

Can someone please help me in improving this process, or guide me alternatives for above process?

Thanks

Suketu

  • 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-05-22T00:47:15+00:00Added an answer on May 22, 2026 at 12:47 am

    You should do the whole process in a stored proc.

    Do not truncate such a large table. Follow the following steps:

    1. Copy the TableB structure to TableB_Copy.
    2. DROP TABLEB.
    3. Rename TableB_Copy to TableB
    4. Disable indexes on TableB
    5. Insert the data from TableA into TableB
    6. Create the indexes on TableB.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large CSV file (Millions of records) I have developed a
I am facing an strange issue. I developed java web app in java 6
Now that Microsoft has revamped their workflow framework in Windows Workflow Foundation 4, what
As we are facing GWT performance issues in a mobile app I peeked into
I'm going to create the comparison table of existing automated C++ refactoring tools as
Good afternoon - I have a pretty general question today - I've been tasked
Most APIs ask developers to get an API key. The API key is then
I have developed an application in WPF and C# as client requirement. Now I
We developed the Drupal based portal. After the testing and deployment (in locally) the
I have a website, where I allow other developers to host content. My aim

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.