We have a MySQL table (table_ha) like this one:
Name = table_ha
+----------+------------------+
| hash_loc | hash_val |
+----------+------------------+
| 242342 | 9606075000001005 |
+----------+------------------+
| 431231 | 9606075000005208 |
+----------+------------------+
| 342344 | 7645345456745536 |
+----------+------------------+
| 324254 | 7656453453465788 |
+----------+------------------+
| 656456 | 9788674534546766 |
+----------+------------------+
| 674453 | 3458752778456834 |
+----------+------------------+
| ... | ... |
+----------+------------------+
| 765874 | 8796634586346785 |
+----------+------------------+
| 864534 | 9834667054534588 |
+----------+------------------+
We continuously execute queries like the following one:
SELECT * FROM table_ha (SELECT 1 AS hash_loc UNION ALL SELECT 28700 UNION ALL SELECT 28728 ... UNION ALL SELECT 28680 UNION ALL SELECT 28694) AS T1 ON table_ha.hash_loc = T1.hash_loc'
We must assume that we might have thousands of numbers in the query (enclosed in UNION ALL SELECT X
). When the number of rows in table_ha is not high, it works ok. Now, imagine having thousands of millions of rows. Then it becomes very slow.
Do you know if partitioning can work in a case like this? How can that be applied to the present table? Do you now any other alternative to this?
NOTE: hashloc is a BigInt(32) and hash_val is a BigInt(64)