Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 循环中的所有查询?是否存在条件(选择)?如果是这样的话,你需要在“代码”中包含这一点,你固执的伴侣也会说你没有接受足够的答案。@Erwin:这是一种非常好的方式,可以向某人介绍相关的常见问题!:)+1(假设我们对SmallQuery中发生的事情进行了一些澄_Sql_Sql Server 2008_Profiling - Fatal编程技术网

Sql 循环中的所有查询?是否存在条件(选择)?如果是这样的话,你需要在“代码”中包含这一点,你固执的伴侣也会说你没有接受足够的答案。@Erwin:这是一种非常好的方式,可以向某人介绍相关的常见问题!:)+1(假设我们对SmallQuery中发生的事情进行了一些澄

Sql 循环中的所有查询?是否存在条件(选择)?如果是这样的话,你需要在“代码”中包含这一点,你固执的伴侣也会说你没有接受足够的答案。@Erwin:这是一种非常好的方式,可以向某人介绍相关的常见问题!:)+1(假设我们对SmallQuery中发生的事情进行了一些澄,sql,sql-server-2008,profiling,Sql,Sql Server 2008,Profiling,循环中的所有查询?是否存在条件(选择)?如果是这样的话,你需要在“代码”中包含这一点,你固执的伴侣也会说你没有接受足够的答案。@Erwin:这是一种非常好的方式,可以向某人介绍相关的常见问题!:)+1(假设我们对SmallQuery中发生的事情进行了一些澄清)我同意@ethrbunny的观点,SQL server将以其优化的速度执行连接,它将比c代码(包括往返)更快。。。您没有根据数据是什么/查询提供任何信息,但(猜测)您应该研究使用EF投影创建组合结果集。@ethrbunny--谢谢。我会考虑


循环中的所有查询?是否存在条件(选择)?如果是这样的话,你需要在“代码”中包含这一点,你固执的伴侣也会说你没有接受足够的答案。@Erwin:这是一种非常好的方式,可以向某人介绍相关的常见问题!:)+1(假设我们对SmallQuery中发生的事情进行了一些澄清)我同意@ethrbunny的观点,SQL server将以其优化的速度执行连接,它将比c代码(包括往返)更快。。。您没有根据数据是什么/查询提供任何信息,但(猜测)您应该研究使用EF投影创建组合结果集。@ethrbunny--谢谢。我会考虑这一点,但问题是,我不知道LINQ是否足够好地完成连接,因为第二个查询涉及几个链接表。因此,考虑到我的这种无能,我想你的答案是我的合作伙伴是正确的,这是一个严重的瓶颈?我同意代码是一个潜在的瓶颈,但你的合作伙伴的解决方案并不理想。@ethrbunny:你是指第三范式吗?+1(假设我们对SmallQuery中发生的事情有一些澄清)我同意@ethrbunny的说法,SQL server将以其优化的方式快速执行连接,它将比c#代码(包括往返)更快。。。您没有根据数据是什么/查询提供任何信息,但(猜测)您应该研究使用EF投影创建组合结果集。@ethrbunny--谢谢。我会考虑这一点,但问题是,我不知道LINQ是否足够好地完成连接,因为第二个查询涉及几个链接表。因此,考虑到我的这种无能,我想你的答案是我的合作伙伴是正确的,这是一个严重的瓶颈?我同意代码是一个潜在的瓶颈,但你的合作伙伴的解决方案并不理想。@ethrbunny:你是说第三范式吗?
Public  string MyWebMethod()
{

List<Record> myrecords = new List<Records>();

try  //try block 1
{
using (AEntityFramework context = new AEntityFramework())
{
var RecordsReturned =   (from x in context.BigTable
                            //some conditions deleted
            select x);

//do some stuff with these records, typically 30 records returned from BigTable, which has 10000 to 100000 records total

foreach (Record r in RecordsReturned)
{  myrecords.Add(r);} //add these records to the List myrecords, to be used later.

}

}
catch (Exception)
{
Try block 1 exceptions here
}
//end of try block 1
//////////////////  now move to the next SQL query, which loops--is this a bottleneck?

foreach (Record R in myrecords)
{
try  //try block 2
{
using (AEntityFramework context = new EntityFramework())
{

    var SmallQuery = (from y in context.SmallTable
                      //some conditions deleted
         select y); 

//small table has 100 to 200 records, it is very small

//do a short operation with the Record R and anything collected by var SmallQuery, typically 2 to 3 entries.


}

}//end of try block 2

catch (Exception)
{
//try block 2 exceptions here
}

} //end of foreach

return “OK”;
}
   List<string> CategoryList = new List<string>() { "Food", "Shelter", "Housing" }; // in one call to the web service method

   List<string> CategoryList = new List<string>() { "Food", "Clothing" }; //in a second call--varies and I don't know ahead of time which is which.