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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:10:43+00:00 2026-05-17T19:10:43+00:00

I have a table with about 1.4 billion records, with the following format: mysql>

  • 0

I have a table with about 1.4 billion records, with the following format:

mysql> describe _2009all;
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| userId        | int(11)      | YES  | MUL | NULL    |       |
| type          | varchar(50)  | YES  |     | NULL    |       |
| kind          | varchar(50)  | YES  |     | NULL    |       |
| description   | varchar(255) | YES  |     | NULL    |       |
| bundleVersion | varchar(255) | YES  |     | NULL    |       |
| bundleId      | varchar(255) | YES  |     | NULL    |       |
| time          | bigint(20)   | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
7 rows in set (0.02 sec)

The entire database takes up less than 0.4 terabytes, and I have about 1.5 terabytes of free disk space available.

I’m trying to prepare the data for analysis where I look at what each user does over time. So I run the following statement:

create table sorted2009 AS (select * from _2009all order by userid,time);

The statement (obviously) takes a long time to run, but at some point, it exhausts the all the free disk space and I get a “ERROR 3 (HY000): Error writing file” error.

Any ideas on how I can create my sorted table? Thanks in advance.

Clarification

Martin: There is only 1 partition.

Andy: The problem I’m trying to solve is that the results of “select * from _2009all order by userid,time” are something that I’m going to be inspecting a lot over the next few months. Thus, rather than running this query every time I want to inspect the results, I want to put the results in a table for faster access.

I had initially assumed that indexing over time would be a waste of space, since timestamps are mostly unique. But I just added an index to the time field in _2009all, and the index takes up a reasonable amount of space. But now to do the sort over the two indexes (what I assume you mean by “indexed walk”):

mysql> select * from _2009all order by userId,time limit 2;
...
2 rows in set (25 min 36.48 sec)

Yes, I’d say 25 minutes is too long. But if you meant something else by your suggestion, I’m open to alternatives.

bot43:

After adding the index to the time field:

mysql> explain select * from _2009all order by userid,time;
+----+-------------+----------+------+---------------+------+---------+------+------------+----------------+
| id | select_type | table    | type | possible_keys | key  | key_len | ref  | rows       | Extra          |
+----+-------------+----------+------+---------------+------+---------+------+------------+----------------+
|  1 | SIMPLE      | _2009all | ALL  | NULL          | NULL | NULL    | NULL | 1384378798 | Using filesort |
+----+-------------+----------+------+---------------+------+---------+------+------------+----------------+
1 row in set (0.05 sec)

mysql> explain select userId,type,kind,description,bundleVersion,bundleId,time from _2009all order by userid,time
+----+-------------+----------+------+---------------+------+---------+------+------------+----------------+
| id | select_type | table    | type | possible_keys | key  | key_len | ref  | rows       | Extra          |
+----+-------------+----------+------+---------------+------+---------+------+------------+----------------+
|  1 | SIMPLE      | _2009all | ALL  | NULL          | NULL | NULL    | NULL | 1384378798 | Using filesort |
+----+-------------+----------+------+---------------+------+---------+------+------------+----------------+
1 row in set (0.00 sec)

Good point about the DBMS storing the table any damn way it feels like it. I guess I need another solution.

  • 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-17T19:10:43+00:00Added an answer on May 17, 2026 at 7:10 pm

    What indexes do you have on the table?

    Can’t you put a composite index on the two columms?

    ALTER TABLE `_2009all` ADD INDEX ( `userId` , `time` ) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that has about 1/2 million records in it. Each month
I have a table of about 1.6M rows where the records have a unique
I have a MySQL table with about 1000 rows, filled with different types of
I have a table of about a million rows and I need to update
I have a fairly simple sync problem. I have a table with about 10
I have a table that holds information about cities in a game, you can
Say I have at database table containing information about a news article in each
I have been reading about the differences between Table Variables and Temp Tables and
I have a basic property bag table that stores attributes about my primary table
I have a question about tables in MySQL. I'm currently making a website where

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.