|
请教一下,我遍历access数据库中点表共9W多个坐标数据,然后用它们计算是否在给定的范围中,再用在范围中的点在线表中获取到包含它们的线的名称,用了1分30秒,我感觉用了好长时间。因为我还要用我查询到的数据生成一个数据库,如果范围再大点,就更费时间了,请指点一下怎么提高效率?
/// <summary>
/// 获取所有含指定管线点名的管线标识码
/// </summary>
/// <param name="connection">一个打开连接的数据库</param>
/// <param name="pesName">管线点名</param>
/// <param name="pesStyleName">管类名</param>
/// <param name="pointTableHz">管线点表后缀名称</param>
/// <param name="lineTableHz">管线线表后缀名称</param>
/// <param name="indexName">标识码字段名称</param>
/// <param name="startCodeName">管线起点名字段名称</param>
/// <param name="endCodeName">管线终点名字段名称</param>
/// <param name="pesPointCodeName">管线点字段名称</param>
/// <returns>返回所有包含指定管线点名的管线标识码</returns>
public static int[] GetPesLineIndexFromPesPointNames(OleDbConnection connection, string pesName, string pesStyleName, string pointTableHz, string lineTableHz,
string indexName, string startCodeName, string endCodeName, string pesPointCodeName)
{
//创建所有起点或终点包含指定管线点的线选择集语句
string lineSqlStr = "select " + indexName + " from " + pesStyleName + lineTableHz + " where " + startCodeName + "='" + pesName + "' union all " +
"select " + indexName + " from " + pesStyleName + lineTableHz + " where " + endCodeName + "='" + pesName + "'" ;
OleDbCommand command = new OleDbCommand(lineSqlStr, connection);
OleDbDataReader oledDbDrLine = command.ExecuteReader();
List<int> indexLst = new List<int>();
while (oledDbDrLine.Read())
{
indexLst.Add(Convert.ToInt32(oledDbDrLine[indexName].ToString()));
}
oledDbDrLine.Close();
return indexLst.ToArray();
}
|
|