0

I have a table that contains about 50 million rows that I have partitioned by 5 million rows per partition. I have manually partitioned it into Table_1, Table_2, Table_3, etc., not using MySql's built-in partition feature using the PARTITION keyword because I didn't know of this feature when I partitioned my table.

A lot of the times, I'll have to retrieve 10 million worth of rows, which would mean I'll have to query 2 partitions worth of data.

It may take anywhere from 2-10 seconds to retrieve the entire data (5 million rows) from just 1 table, which is pretty slow. Though after the initial query, the same query would be very fast (a few hundred ms).

Would partitioning my table(s) using the built in MySql partition feature help querying faster in my case?

1 Answer 1

2

Run the same queries twice. Did they run faster the second time? Guess what. The first time the data was sitting on disk and had to be pulled from disk. The second time, it was all sitting in RAM. The difference might be 10-fold.

Why would you ever fetch 5M rows at once? And, if you split 50M rows into 10 'partitions', why would that 5M be relevant? Might you need a different slice of the data?

Partitioning, either manually, or with PARTITION, rarely provide any performance benefit for real tasks.

If you often need to fetch 10M rows, let's discuss ways to avoid fetching that many rows, yet still get the same answer. Using Summary Tables is a common technique in Data Warehousing.

Provide more details, and I will explain in more detail why I am throwing cold water on your Question.

2
  • I have no idea why I said I fetch 5m rows at once. I need to go to bed. I fetch around 200,000 rows at most, but on average it's less than 100,000 rows. I'll come back tomorrow to edit the question and add more details. Thank you.
    – juung666
    Commented Feb 2, 2019 at 13:37
  • @RestInPeace - Even 100K rows in a single SELECT seems excessive (certainly for web applications). What kind of app is it?
    – Rick James
    Commented Sep 9, 2022 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.