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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:50:46+00:00 2026-06-06T16:50:46+00:00

Thanks in advance for taking the time to read my question. I’m using MySQL

  • 0

Thanks in advance for taking the time to read my question. I’m using MySQL and Python together and I’m executing first this SQL command

  SELECT T1.col1 AS t, T1.col4 AS d, T2.col3 AS e, T2.col4 AS d, T2.col7 AS p,
  T2.col13 AS de, 
  T2.col5 AS carrier, T2.col12 AS f, T2.col10 AS c
  FROM table AS T1
  JOIN table_c AS T2 ON T1.col1 = T2.col1
  ORDER BY RAND( )
  LIMIT 100000 ;

The databases I’m working on are quite big (T1 is of 300 000 000 lines and T2 is of 300 000 lines) and I created them thanks to phpMyAdmin . I created indexes also on the col1 of T1 and col1 of T2. But when I run the SQL command it gets stuck on the copying to tmp table phase message ( I left it for the whole weekend and it’s still at the same point)

I tried modifying the parameter tmp_table_size but it didn’t change anything

I have no idea what could be the solution for me to execute this command in a reasonable time

All suggestions are welcome

Thank you so much for your help

  • 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-06T16:50:48+00:00Added an answer on June 6, 2026 at 4:50 pm

    The ORDER BY RAND() trick should never be used with such large table sizes. ORDER BY RAND() works by assigning a random value for each row in your JOINed result set (in your case probably hundreds of millions of rows), actually creating all those rows, sorting them on disk, and if it’s ready, only then can it choose and return the top 100000 rows for you.

    Solutions are not obvious, but you can find some techniques to fight with your problem, like
    How can i optimize MySQL's ORDER BY RAND() function?

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

Sidebar

Related Questions

First, thanks in advance for taking the time to read through this. I have
Thanks in advance for taking the time to read this. Apologies that it is
thanks in advance for taking the time to read through my question... /* Binary
Hi there and thanks for taking the time for this question. I'm using a
I know this is simple question but taking more time How to find first
and first of all, thank you for taking the time to read my question.
Thanks for taking the time to read my question. I am looking for advice
Hello everybody and thanks for taking the time to read this ; I was
Thanks in Advance for reading and answer this question. I got button in asp
Thanks for taking the time to answer my question. I want to check if

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.