comment comment - 1 year ago 55
MySQL Question

Saving all records to next database if the first database is reached its size limit

I am planning to apply web hosting in they offer 10 databases and 1GB each. I am creating a site that saving a lots of records. My question is:

1) How can I check the database if it is near 1GB ?

2) How can I automatically select the next database if the previous database reached its limit(1GB) ?

3) How can I echo all results(in those 10 databases), that is related to the set


4) How can I echo all results(10 databases) depends on the type of the record ? (like: female or male)

If you have suggested a tutorials or anything that is related to my concern. I will appreciate it alot.

Answer Source


SELECT table_schema "Data Base Name",
    sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
    sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ; 

2) You can't do this automaticly

3) You should write own solution for that. Normaly is something as database shard But is used to scalability large databases configured to work with many nodes.

4) like point 3

But is wrong way at all. They give 10 small databases to separate project not for scaling large one. Writing solution like that by yourself will be more expensive than cost large database and maybe never work fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download