2016-09-26 4 views
-1

私はデータベースを使ってアプリケーションを作成しています。私は私のデータベースのいくつかの無料のホスティングを見つけましたが、私は自分のデータベースに十分なメモリがあるかどうかはわかりません。だから、私の質問はどのくらいのレコード(行)が各テーブルを持つことがわかっている場合、ハードディスク上のどのくらいのメモリが私のデータベースを取るか計算する方法ですか? PS:データベースには数字やテキストだけのメディア(写真、音楽など)はありません。必要なデータベースのメモリ量を計算するには?

答えて

1

ここでは、より経験豊富な答えはありませんが、エレガントではないが、あなたに出発点を与える必要があります。これは、this link

1. Construct a dummy table that is set up **exactly** how you want your real table to be. 

2. Write a query that inserts 10000 random rows into the table. 
    You can use a scripting language for this. 
    For example, if you have three columns, all with varchar(100), try using php to write this query" 

    $col1_Val = str_repeat('x', mt_rand(0,100)); 
    $col2_Val = str_repeat('y', mt_rand(0,100)); 
    $col3_Val = str_repeat('z', mt_rand(0,100)); 

    $bulk_query = "INSERT INTO my_dummy_table (col1, col2, col3) VALUES ($col1_Val, $col2_Val, $col3_Val),"; 

3. Concatenate to create a statement that will do 10000 inserts: 
    for($i = 0; $i < 9999; $i++) { 
     $col1_Val = str_repeat('x', mt_rand(0,100)); 
     $col2_Val = str_repeat('y', mt_rand(0,100)); 
     $col3_Val = str_repeat('z', mt_rand(0,100)); 
     $bulk_query .= ",($col1_Val, $col2_Val, $col3_Val)"; 
    } 

4. Now the query has been constructed. 
    Echo it or copy it in whichever way and then run the query from a script, PHPAdmin, command line, etc. 

5. Now get the table size either using the link above, PHPAdmin, etc. 

6. Divide the table size by 10000. 
    This is your `average space requirement per row`. 

7. If you know roughly how many rows your table will need, multiply `number of rows` by `average space requirement per row`. 
    This your **estimated space requirement**. 
関連する問題