Quantcast
Channel: Martin Dráb's Activities
Viewing all articles
Browse latest Browse all 17532

Improve View Computed Column Performance

$
0
0

Hi,

I created a Service Order Listing View which includes service order header and service order lines as main datasource.

There are several computed columns in the view, but one column gave significant performance impact. The column is non primary phone number for the customer service address. User need this field for sorting & filtering.

    private static server str contactNo2()
    {
        DictView dv = new DictView(tableNum(ServiceOrderListingView));

        //str s = strFmt("select distinct top 1 LOCATOR from DIRPARTYPOSTALADDRESSVIEW "+
        //    "join DIRPARTYTABLE on DIRPARTYTABLE.RECID = DIRPARTYPOSTALADDRESSVIEW.PARTY "+
        //    "join DIRPARTYLOCATION on DIRPARTYLOCATION.PARTY = DIRPARTYTABLE.RECID "+
        //    "join LOGISTICSLOCATION on LOGISTICSLOCATION.RECID = DIRPARTYLOCATION.LOCATION "+
        //    "join LOGISTICSELECTRONICADDRESS on LOGISTICSELECTRONICADDRESS.LOCATION = LOGISTICSLOCATION.RECID "+
        //    "and LOGISTICSELECTRONICADDRESS.ISPRIMARY = 0 and LOGISTICSELECTRONICADDRESS.TYPE = 1 "+
        //    "where DIRPARTYPOSTALADDRESSVIEW.XRECID_LOGISTICSPOSTALADDRESS = %1",
        //    dv.computedColumnString(tableStr(SMAServiceOrderTable), fieldStr(SMAServiceOrderTable, ServicePostalAddress), FieldNameGenerationMode::WhereClause));

        str s = strFmt("select top 1 LOGISTICSELECTRONICADDRESS.LOCATOR from logisticspostaladdress "+"inner join DIRPARTYLOCATION dirpartylocation2 on dirpartylocation2.LOCATION = logisticspostaladdress.LOCATION "+"inner join LOGISTICSLOCATION logisticslocation2 on logisticslocation2.RECID = logisticspostaladdress.LOCATION "+"inner join DIRPARTYTABLE on DIRPARTYTABLE.RECID = dirpartylocation2.PARTY "+"inner join DIRPARTYLOCATION on DIRPARTYLOCATION.PARTY = DIRPARTYTABLE.RECID "+"inner join LOGISTICSLOCATION on LOGISTICSLOCATION.RECID = DIRPARTYLOCATION.LOCATION "+"inner join LOGISTICSELECTRONICADDRESS on LOGISTICSELECTRONICADDRESS.LOCATION = LOGISTICSLOCATION.RECID "+"and LOGISTICSELECTRONICADDRESS.ISPRIMARY = 0 and LOGISTICSELECTRONICADDRESS.TYPE = 1 "+"where LOGISTICSPOSTALADDRESS.RECID = %1",
            dv.computedColumnString(tableStr(SMAServiceOrderTable), fieldStr(SMAServiceOrderTable, ServicePostalAddress), FieldNameGenerationMode::WhereClause));



        return strFmt('ISNULL((%1), \'\')', s);
    }

Because of this field, the view needs around 2 minutes to load 1000 rows. Without it, the view can load 19k++ rows within 10 seconds.

How can we improve the computed column query? The query goes through a lot of table for a single column.

Is there any shorter query to get non primary phone number from address?

Thank you.


Viewing all articles
Browse latest Browse all 17532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>