Blob数据获取速度太慢

时间:2014-06-24 10:23:08

标签: c# mysql sql

我将180个平铺的图像数据存储到MySQL数据库中。每块瓷砖大约10KB。

当我尝试使用ONE连接和SINGLE查询从MySQL数据库中获取所有切片时,它需要200毫秒,这对我来说非常慢。

有没有办法让它更快?

这是我的“ filedata ”表格。 (我尝试过MyISAM和INNODB。结果是一样的:()

id (int) **PrimaryKey**
layerid (int)
channelid (int)
stratumid (int)
x (int)
y (int)
tiledata (MEDIUMBLOB)

这是我用于测试查询的控制台应用程序。

Console.ReadKey();

Stopwatch swx = new Stopwatch();
swx.Start();

    MySqlConnection conn = new MySqlConnection("Server=127.0.0.1;Port=3306;Database=trying;Uid=root;Pwd=;Encrypt=false;AllowUserVariables=True;UseCompression=True;");
    conn.Open();


Console.WriteLine("Connection open.");

swx.Stop();

Console.WriteLine("Conn Open Time = " + swx.ElapsedMilliseconds.ToString());

Console.ReadKey();
Stopwatch sw = new Stopwatch();
sw.Start();
MySqlCommand com = conn.CreateCommand();
com.CommandText = "SELECT filedata FROM filedata where layerid = '5'";
MySqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
    byte[] b = (byte[])reader[0];
}
reader.Close();
sw.Stop();
Console.WriteLine("Time= " + sw.ElapsedMilliseconds.ToString());
Console.ReadKey();

我的电脑是;

处理器:i7 2,67 Ghz, RAM:6 GB, HDD:1 TB SSD。

0 个答案:

没有答案
相关问题