I have a large table with around half a million rows which is taking a toll on the shared hosting server. I am suppose to break down this large table into 3-4 smaller tables as we have no other option in shared hosting environment. While breaking down, I will keep that large table as it is and will take out only a specific column which contains large amount of text and split it into smaller tables.
What I am looking for now is a solution wherein I have to do minimum changes to the PHP code and the table can be split into several ones as follows:
main_table
id | column1 | column2 | column3_just_pointer
smaller_table_1
id | main_table_id | column3
smaller_table_2
id | main_table_id | column3
smaller_table_3
id | main_table_id | column3
If MySQL has something like pointer that can point to column3 in smaller table on executing a select command: select id, column3_just_pointer from main_table, I can split the tables in above mentioned fashion and the front end PHP code does not need to be edited at all.
I hope I sounded clear. Does any one here have any idea as to if and how this can be achieved? Thank you for your time…
Please Note: views cannot be used as it will prevent me from creating multiple smaller tables.
I ended up totally partitioning the tables horizontally with names like smaller_table_1,smaller_table_2,etc and keeping a record of the starting and ending ids of each table in a separate table say ‘main_table’. New data is added only to the last table and when a table crosses 40000 rows, my application automatically creates a new table smaller_table_n and put the information of that new table into main_table.
I had asked this question in March and till now – July, this setup as worked flawlessly in 3 of my websites and all my 3 hosts too are happy about the sites not taking up more resources on their server.