Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 200011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:04:27+00:00 2026-05-11T17:04:27+00:00

Well I have a series of sps that are running a data warehousing solution

  • 0

Well I have a series of sps that are running a data warehousing solution that we have developed in house. While on the most part it runs pretty good, there is one stored procedure that runs really slow. It takes about 30 minutes on average to execute. I know exactly where the bottle neck is, I just don’t know how to fix it.

Basically what the stored procedure does is create a series of variable temp tables and insert into those tables. no problem there. it then joins the temp tables and inserts into another temp table, twice (the second one is a little different).

this is the statement that joins the tables and inserts into the temp table, and is the part that takes forever. any help would be greatly appreciated.

; with Requested as
(
    select distinct 
        PONUMBER as PONumber, 
        min(REQSTDBY) as RequestedBy
    from dw.POP10110
    where REQSTDBY <>''
    group by PONUMBER
)
insert into @tblTableA
(
    PONumber, 
    ReceiptNumber,
    ReceiptLineNumber, 
    VendorID, 
    POType, 
    QuantityShipped, 
    QuantityInvoiced,
    ItemNumber, 
    ItemDescription, 
    UofM, 
    UnitCost, 
    ExtendedCost, 
    SiteID,
    ProjectNumber, 
    AccountID, 
    RequestedBy, 
    GLPostDate, 
    VendorName, 
    CostCategoryID
) 

select 
    a.PONUMBER, 
    a.POPRCTNM, 
    a.RCPTLNNM, 
    a.VENDORID, 
    a.POPTYPE, 
    a.QTYSHPPD, 
    a.QTYINVCD,
    b.ITEMNMBR,
    b.ITEMDESC,
    b.UOFM,
    b.UNITCOST,
    b.EXTDCOST,
    b.LOCNCODE,
    b.ProjNum,
    case i.CostCategoryID 
        when 'MISC' then isnull(i.AccountID,'N/A')

        else 
            case j.CostCategoryID 
                when 'MISC' then 
                    isnull(j.AccountID,'N/A')

                else 
                    isnull(c.PurchaseAccount,'N/A') 
            end
    end as AccountID,
    d.RequestedBy,
    coalesce(e.GLPOSTDT, f.GLPOSTDT, '') as GLPostDate,
    coalesce(e.VENDNAME, f.VENDNAME, '') as VENDNAME,
    case i.CostCategoryID when 'MISC' then i.CostCategoryID else 
        case j.CostCategoryID when 'MISC' then j.CostCategoryID else coalesce(g.CostCategoryID, h.CostCategoryID, '') end
    end as CostCategoryID

from dw.POP10500 a
    inner join dw.POP30310 b
        on a.PONUMBER=b.PONUMBER
            and a.POPRCTNM=b.POPRCTNM
            and a.RCPTLNNM=b.RCPTLNNM
    left outer join @gl00100 c
        on b.INVINDX=c.ActID
    left outer join Requested d
        on b.PONUMBER = d.PONumber
    left outer join dw.POP30300 e
        on b.POPRCTNM=e.POPRCTNM
    left outer join dw.POP10300 f
        on b.POPRCTNM=f.POPRCTNM
    left outer join @pop31310 g
        on b.POPRCTNM=g.ReceiptNumber
    left outer join @pop11310 h
        on b.POPRCTNM=h.ReceiptNumber
    left outer join @pop30390 i
        on a.POPRCTNM=i.ReceiptNumber
    left outer join @pop10390 j
        on a.POPRCTNM=j.ReceiptNumber

As far as i am aware the appropriate indexes are in place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:04:27+00:00Added an answer on May 11, 2026 at 5:04 pm

    added statistics to some of the tables and an index and it cut the time down from 25 minutes to 9 minutes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a teamcity install that runs a series of unit tests. I added
I have developed a CakePHP application that does basic CRUD on a series of
I have a graph, well, a series of disconnected graphs in Neo4j. I want
well i have a configuration like this in the components part of my config
Well i have a div tag that i show as a modal dialog this
well I have that problem, im using a lightbox srcipt and im opening an
well i have most probably an extremly stupid problem but could not figure it
I have a series of shapes that I want the user to be able
I have a checkbox that allows my program to enable disable series displayed on
I have an application that needs to render about 100 flash graphs (as well

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.