SQL选择的优化统计员
-
27-09-2019 - |
题
如何这个查询统计员进行优化:
SELECT * FROM Customers
Table Customers
customerId int - has index on it
customerName, etc
SQLReader的该返回的一组客户将点播在枚举的方式被读出。虽然它可以返回foreach循环慢慢耗可以读取庞大数据集/,在同一个表中的每个其他查询会遇到很多争论的。这怎么可能优化/避免?光标或选择到临时表?
下面是一个代码示例,这将导致大量的争论(我异形它和数字看起来确实不好)的:
public void DumpCustomers()
{
Thread thread = new Thread(AccessCustomers);
thread.Start();
// GetCustomers returns enumerator with yield return; big # of customers
foreach (Customer customer in GetCustomers())
{
Console.WriteLine(customer.CustomerName);
System.Threading.Thread.Sleep(200);
}
thread.Abort();
}
public void AccessCustomers()
{
while (true)
{
Console.WriteLine(GetCustomer("Zoidberg").CustomerName);
Thread.Sleep(100);
}
}
,点击 的 P.S。我还需要在MySQL优化该强>
解决方案
1)你所需要的 '*' 着你指定列。
2)使用多部分的名称dbo.tablename.fieldname - 这个速度它
3)尝试锁定提示与(NOLOCK)或(READPAST)
4)请告诉我IO配置文件?确实有SQL每次运行时拉从磁盘上的数据?
5)你觉得在你的服务器最大的核心了,而另外一个是空闲的一个?
6)高速缓存了!直到你知道又有了变化 - 然后重新装入。
我的想法跑了..
不隶属于 StackOverflow