zoukankan      html  css  js  c++  java
  • 善用Axapta当中的exists join和inner join

    其实我也发现这个问题了,

    但是Junevoful已经说的很详细了,我就补充两点:

    1,使用exists join不可以引用第二个表的数据,表示÷这条数据一旦存在于第二个表中,就认为满足条件,但是使用inner join可以引用第二个表的数据,是内关联。

    2,大家可以使用Axapta本省带的Sql性能监视器来监视Sql语句的执行效率,启动的方法是:

     

     

    下面我就引用一下Junevoful的文章,他说的很详细,也很精彩,谢谢他给我带了这么好的文章!

     

    前几天,在做系统优化的时候,居然发现代码当中存在while嵌套循环语句

    while select table 1

    {

    ..

    while select table2

    以前并不太在意,但是既然要系统优化,就只怕没找到东西可以改的。

    突然忽发奇想,何不测试一下这样做的系统开销有多大呢?于是写了三个job,进行测试

    static void TestInnerJoinUsingWhile(Args _args)

    {

           ...

           ;

           startTime = WinApi::getTickCount();

           while select ledgerTrans

           where ledgerTrans.AccountNum == accountNum &&

           ((ledgerTrans.TransDate >= 1/7/2005 &&

           ledgerTrans.TransDate <= 31/7/2005))

           {

           while select projTransPosting

           where projTransPosting.Voucher == ledgerTrans.voucher &&

           projTransPosting.Account == accountNum

           {

           ...

           tmpFRD_LedgerDriDwnContractDtls.insert();

     

           }

           }

           endTime = WinApi::getTickCount();

           duration = endTime - startTime;

           Info(int2str(duration));

    }

     

    static void TestInnerJoinUsingJoin(Args _args)

    {

           while select ledgerTrans

           where ...

           join projTransPosting

           where ...

    }

     

    static void TestExistsJoinUsingJoin(Args _args)

    {

           ...

           while select ledgerTrans

           where ...

           exists join projTransPosting

           where ...

    }

    结果发现使用嵌套while的时间是4012微秒,Inner join1986微秒,exists join1689微秒。

    可见在写代码的时候,还是需要按照Best Practice的要求,这样才能获得最好的performance

  • 相关阅读:
    Django使用xadmin集成富文本编辑器Ueditor(方法二)
    Django-xadmin后台配置富文本编辑器(方法一)
    求解函数不等式[给定具体函数]
    区间断想
    函数方程和函数不等式
    对函数的再理解
    多题一解
    破解函数性质中的表达难点
    [数学模型]应用举例
    函数的迭代
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2761586.html
Copyright © 2011-2022 走看看