query performance  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

query performance  Topic is solved

Postby perry » Fri Jun 25, 2021 6:43 pm

Hi All,
A customer is having some performance issue and Azure DB caught few expensive queries.

I have search across all stored procedures and custom plugin and none of them contains "HAVING SUM(IN_SOH.QuantityLeft) > 0"

It also doesn't look like a query from report to me.

Anyone has suggestion on which part of Jiwa uses below query?


Code: Select all
SELECT IN_SOH.InventoryID
FROM IN_SOH WITH (NOLOCK)
LEFT JOIN SO_Lines WITH (NOLOCK) ON SO_Lines.InventoryID = IN_SOH.InventoryID
LEFT JOIN SO_History WITH (NOLOCK) ON SO_History.InvoiceHistoryID = SO_Lines.InvoiceHistoryID
LEFT JOIN SO_Main WITH (NOLOCK) ON SO_Main.InvoiceID = SO_History.InvoiceID
WHERE (SO_Lines.InvoiceLineID IS NULL OR ((SO_Main.Status=1 OR SO_Main.Status=2) OR SO_History.HistoryNo <> SO_Main.CurrentHistoryNo))
AND (SO_Lines.InvoiceLineID IS NULL OR CreditNote = 0)
AND SO_Lines.InvoiceLineID IS NULL
GROUP BY IN_SOH.InventoryID
HAVING SUM(IN_SOH.QuantityLeft) > 0
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: query performance

Postby Mike.Sheen » Sat Jun 26, 2021 12:15 pm

perry wrote:Anyone has suggestion on which part of Jiwa uses below query?


It's not the Jiwa application - I searched all the Jiwa source code for each of the following and got no results:

  • "HAVING SUM(IN_SOH.QuantityLeft) > 0"
  • "HAVING SUM("
  • "GROUP BY IN_SOH.InventoryID"

If the query you show hasn't been beautified, then it's not a query from a Crystal Report, either - Crystal has a certain way of joining tables and it's not as pretty as what we see here.

Have you looked in triggers?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: query performance

Postby DannyC » Mon Jun 28, 2021 4:57 pm

Have you looked through all views?

Try this SQL in a query window
Code: Select all
SELECT OBJECT_NAME( object_id ), *
  FROM sys.sql_modules
WHERE [definition] LIKE '%HAVING SUM(IN_SOH.QuantityLeft) > 0%';
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: query performance

Postby perry » Mon Jun 28, 2021 5:22 pm

Thanks both,
not in triggers nor views...

I may check with the web guy, it looks like getting list of item was never invoiced.
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests