(773) 860-0643  

  • "It’s been really nice working with you, Jamie and Ruby! Thank you for your continued support to Frank, Rimerman Consulting."

    Beverly MCSM (GP Partner)
  • "Thanks for the late-night support the other night!... Client was operating as it should this morning!   WOOO HOOOO !"

    Maureen ACAE (GP Partner)
  • "Have I told Alba-Spectrum this year yet how F A S T the newsletter selection is now ???? Wow. Thank you very much!"

    Dennis Westbrook
  • "We were successful last night in completing the production deployment of Terminations WF. Ricardo was fantastic and we could not have done this without him"

    Tawna KProject Manager (Credit Management)
  • "[We are] so grateful for Jeff’s help, and Jeff has been so good to...ZTrim in all of his support."

    John ECFO (Agricultural Ingredient Technology)
  • "First off, thanks for all the great suggestions. I’ll let you know what we find out. Many thanks for your help"

    Mark BDeveloper (Telephone Company)
  • "I will e-mail you back to let you know I was successful with HJE – which I expect to be. I really appreciate how you helped me."

    Michele DurkinConsultant (GP Partner)
  • "...thank you both for taking some time out to help me troubleshoot the issue of creating a project directly into the GP tables without the benefit of using the web services."

    Jesse CPrincipal (GP Partner)
  • "For example, when an AE calls to confirm rates, there’s not a 30 second pause waiting for the billing schedule to open. It’s absolutely immediate, literally, click, click, click. It’s a huge difference."

    Vince FCredit Manager (Media Data Service)
  • "So far everything seems to be working fine. We have had it in production now for almost a month and have not experienced any problems."

    Mark MFinance Manager (Custom Woodwork)
  • "Alba will always be my choice for quality innovation on ANY project you put in their lap from websites to Great Plains implementations, customizations and people who think 'outside the box'. "

    Robert DCEO
  • "Rod, your team’s flexibility and quality of service have been appreciated."

    Nicholas NController (Financial Trading)
  • "I most heartily and sincerely recommend him and his firm for any software implementation task."

    John PCFO (Tourism Association)
  • "[the] team delivered several enhancements to Great Plains, significantly improving our sales order entry process, shipment routing, and handling of catch-weight items."

    Eddie HPresident (Food Products)
  • "You have come very highly recommended by other companies. I have been impressed with your professionalism and attention to detail."

    Timothy CPresident (Uniform Manufacture)
  • "I am very happy that Andrew was able to fix our invoice system. Your company is very professional and performs excellent service."

    Allen ZCFO (Oil Company)
  • "I don't know who your company president is, but you guys did great job and I hope he/she sees this email."

    Nathan M.Finance (Marketing Communications)
  • "I heartily recommend Alba to any developer or end user seeking to make the most of their GP investment."

    Brett GPresident (Software Development)
  • "Thank you for all your patience and hard work getting this all processed. Here at Friedr Dick Corp we are looking forward to a wonderful professional relationship."

    Jill DAccounting Manager (Home Furnishings)
  • "I think we are going to be a great team working forward on the Miami project."

    Jesse CPrincipal (GP Partner)
  • "As usual, superb product and service!! Everything is working great and all my users love the modification. Thanks again!"

    Michael LController (Healthcare Storage)
  • "[W]e thought your product GP Posting Server was the better solution. The interface is better, it is easier to understand, and there are more options considering the auto transfer feature. We compared it to the Envisage Post Master Enterprise software."

    Tom BSenior IT Administrator (Medical Implements Company)
Customer Feedback
  • "It’s been really nice working with you, Jamie and Ruby! Thank you for your continued support to Frank, Rimerman Consulting."

    Beverly MCSM (GP Partner)
  • "Thanks for the late-night support the other night!... Client was operating as it should this morning!   WOOO HOOOO !"

    Maureen ACAE (GP Partner)
  • "Have I told Alba-Spectrum this year yet how F A S T the newsletter selection is now ???? Wow. Thank you very much!"

    Dennis Westbrook
  • "We were successful last night in completing the production deployment of Terminations WF. Ricardo was fantastic and we could not have done this without him"

    Tawna KProject Manager (Credit Management)
  • "[We are] so grateful for Jeff’s help, and Jeff has been so good to...ZTrim in all of his support."

    John ECFO (Agricultural Ingredient Technology)
  • "First off, thanks for all the great suggestions. I’ll let you know what we find out. Many thanks for your help"

    Mark BDeveloper (Telephone Company)
  • "I will e-mail you back to let you know I was successful with HJE – which I expect to be. I really appreciate how you helped me."

    Michele DurkinConsultant (GP Partner)
  • "...thank you both for taking some time out to help me troubleshoot the issue of creating a project directly into the GP tables without the benefit of using the web services."

    Jesse CPrincipal (GP Partner)
  • "For example, when an AE calls to confirm rates, there’s not a 30 second pause waiting for the billing schedule to open. It’s absolutely immediate, literally, click, click, click. It’s a huge difference."

    Vince FCredit Manager (Media Data Service)
  • "So far everything seems to be working fine. We have had it in production now for almost a month and have not experienced any problems."

    Mark MFinance Manager (Custom Woodwork)
  • "Alba will always be my choice for quality innovation on ANY project you put in their lap from websites to Great Plains implementations, customizations and people who think 'outside the box'. "

    Robert DCEO
  • "Rod, your team’s flexibility and quality of service have been appreciated."

    Nicholas NController (Financial Trading)
  • "I most heartily and sincerely recommend him and his firm for any software implementation task."

    John PCFO (Tourism Association)
  • "[the] team delivered several enhancements to Great Plains, significantly improving our sales order entry process, shipment routing, and handling of catch-weight items."

    Eddie HPresident (Food Products)
  • "You have come very highly recommended by other companies. I have been impressed with your professionalism and attention to detail."

    Timothy CPresident (Uniform Manufacture)
  • "I am very happy that Andrew was able to fix our invoice system. Your company is very professional and performs excellent service."

    Allen ZCFO (Oil Company)
  • "I don't know who your company president is, but you guys did great job and I hope he/she sees this email."

    Nathan M.Finance (Marketing Communications)
  • "I heartily recommend Alba to any developer or end user seeking to make the most of their GP investment."

    Brett GPresident (Software Development)
  • "Thank you for all your patience and hard work getting this all processed. Here at Friedr Dick Corp we are looking forward to a wonderful professional relationship."

    Jill DAccounting Manager (Home Furnishings)
  • "I think we are going to be a great team working forward on the Miami project."

    Jesse CPrincipal (GP Partner)
  • "As usual, superb product and service!! Everything is working great and all my users love the modification. Thanks again!"

    Michael LController (Healthcare Storage)
  • "[W]e thought your product GP Posting Server was the better solution. The interface is better, it is easier to understand, and there are more options considering the auto transfer feature. We compared it to the Envisage Post Master Enterprise software."

    Tom BSenior IT Administrator (Medical Implements Company)

Performance Issue with Left Outer Join on Large Tables Involving Character Fields

Overview

When doing SQL left outer joins on a particular field that needs to have some string operations performed may considerably affect performance especially when the table involved contains high volume of records.

SQL Server Version

Microsoft SQL Server 2008

Details

In SQL, the WITH statement can be used to create a temporary query table that can be used within a given procedure:

;WITH CARDS AS (

SELECT CAST(@CARDSEQ1 AS NUMERIC(20)) AS NUM

UNION ALL

SELECT CAST(NUM + 1 AS NUMERIC(20))

FROM CARDS

WHERE NUM < @CARDSEQ2

However, we should be mindful about some potential potholes when using this temporary table within the procedure. Sometimes, even if the SQL procedure has been correctly written such that it can be executed without error, and is capable of returning the correct output, it still cannot not guarantee the effectiveness especially if it involves going through a temporary table with considerably huge volume of records.

Such is the case when trying to use a REPLICATE statement on a field from the said temporary table, as part of the WHERE clause while doing a LEFT OUTER JOIN.

To illustrate, here is a SELECT statement that will be referring to the temporary table CARDS.

SELECT ISNULL(B.ALB_Sequence_Number, 0), ISNULL(B.ALB_CARD_NUMBER, ''), ISNULL(B.LOTNUMBR, ''), ISNULL(B.DATERECD, '1900-01-01'), ISNULL(B.DTSEQNUM, 0), 0, CASE C.ITEMNMBR WHEN NULL THEN 0 ELSE 1 END, @USERID, ISNULL(B.ALB_Card_Sequence, ''), ISNULL(B.ALB_DENOMINATION, 0)

FROM CARDS A

LEFT OUTER JOIN ALBIV10003 B ON

B.ITEMNMBR = @ITEMNMBR AND B.LOCNCODE = @LOC AND

ALB_CARD_SEQUENCE = REPLICATE('0', @LENGTH - LEN(CAST(NUM AS VARCHAR(20)))) + CAST(NUM AS VARCHAR(20)) AND

B.ALB_DENOMINATION = @DENOMINATION

LEFT OUTER JOIN ALBSOP10201 C ON

C.ITEMNMBR = @ITEMNMBR AND

C.ALB_CARD_SEQUENCE = REPLICATE('0', @LENGTH - LEN(CAST(NUM AS VARCHAR(20)))) + CAST(NUM AS VARCHAR(20)) AND

C.ALB_DENOMINATION = @DENOMINATION

Notice that in the highlighted statement “REPLICATE('0', @LENGTH - LEN(CAST(NUM AS VARCHAR(20)))) + CAST(NUM AS VARCHAR(20))”, it is referencing a field NUM from the temporary table CARDS.

This script when executed where the temporary table CARDS returned approximately 500,000 records, has been running for more than ten (10) minutes or so before we decided to just terminate the process.

We then attempted to tweak the script by transferring the highlighted REPLICATE statement to the select statement on the temporary table CARDS instead of doing it on the LEFT OUTER JOIN:

 ;WITH CARDS AS (

SELECT CAST(@CARDSEQ1 AS NUMERIC(20)) AS NUM, CAST(REPLICATE('0', @LENGTH - LEN(CAST(@CARDSEQ1 AS VARCHAR(20)))) + CAST(@CARDSEQ1 AS VARCHAR(20)) AS VARCHAR(20)) AS TEMPCARDSEQ

UNION ALL

SELECT CAST(NUM + 1 AS NUMERIC(20)), CAST(REPLICATE('0', 12 - LEN(CAST(NUM + 1 AS VARCHAR(20)))) + CAST(CAST(NUM + 1 AS NUMERIC(20)) AS VARCHAR(20)) AS VARCHAR(20)) AS TEMPCARDSEQ

FROM CARDS

WHERE NUM < @CARDSEQ2

) 

The output of this REPLICATE statement was then assigned to the field TEMPCARDSEQ. Now, in the previous select statement, we just have to replace the REPLICATE statement with the new temporary field TEMPCARDSEQ.

SELECT ISNULL(B.ALB_Sequence_Number, 0), ISNULL(B.ALB_CARD_NUMBER, ''), ISNULL(B.LOTNUMBR, ''), ISNULL(B.DATERECD, '1900-01-01'), ISNULL(B.DTSEQNUM, 0), 0, CASE C.ITEMNMBR WHEN NULL THEN 0 ELSE 1 END, @USERID, ISNULL(B.ALB_Card_Sequence, ''), ISNULL(B.ALB_DENOMINATION, 0)

FROM CARDS A

LEFT OUTER JOIN ALBIV10003 B ON B.ITEMNMBR = @ITEMNMBR AND

B.LOCNCODE = @LOC AND

ALB_CARD_SEQUENCE = A.TEMPCARDSEQ AND

B.ALB_DENOMINATION = @DENOMINATION

LEFT OUTER JOIN ALBSOP10201 C ON C.ITEMNMBR = @ITEMNMBR AND

C.ALB_CARD_SEQUENCE = A.TEMPCARDSEQ AND

C.ALB_DENOMINATION = @DENOMINATION OPTION (MAXRECURSION 0);

This modified script, when executed using the same temporary table CARDS with 500,000 records, took just 1 minute and 15 seconds to finish.

In conclusion, there was no major rewrite involved to optimize the script. There wasn’t even a change in the way the conditions nor the statements where written. What we did was just to move certain parts of the script, essentially allowing bulk of the REPLICATE operation to execute at the same time as when the temporary table CARDS is being created. This resulted to a more optimized script, ultimately improving the performance of the script.