Go to Project Management and Accounting -> Common -> Project Invoices -> project invoice proposals
When I double click to open an invoice proposal (any of the proposals listed), it takes ~50 sec. Below is the query, it's returning the contents of the entire table:
SELECT T1.PROJINVOICEPROJID,
...
...
FROM PROJPROPOSALJOUR T1 LEFT
OUTER
JOIN DAT1SERVICEORDERPROPOSALUNION T2 ON (((T2.PARTITION=5637144576)
AND (T2.DATAAREAID=N'xxx'))
AND (T1.PROPOSALID=T2.PROPOSALID)) LEFT
OUTER
JOIN PROJFUNDINGSOURCE T3 ON (((T3.PARTITION=5637144576)
AND (T3.DATAAREAID=N'xxx'))
AND ((T1.FUNDINGSOURCE=T3.RECID)
AND (T1.FUNDINGSOURCE=T3.RECID))) LEFT
OUTER
JOIN FISCALESTABLISHMENT_BR T4 ON (((T4.PARTITION=5637144576)
AND (T4.DATAAREAID=N'xxx'))
AND (T1.FISCALESTABLISHMENT_BR=T4.RECID)) LEFT
OUTER
JOIN FISCALDOCUMENTTYPE_BR T5 ON (((T5.PARTITION=5637144576)
AND (T5.DATAAREAID=N'xxx'))
AND (T1.FISCALDOCUMENTTYPE_BR=T5.RECID))
WHERE (((T1.PARTITION=5637144576)
AND (T1.DATAAREAID=N'xxx'))
AND (T1.RECID<?))
ORDER BY T1.RECID DESC OPTION(FAST 6)
However If in the list of invoice proposals, I first do some filtering by putting the exact proposal i'm looking for, so that the grid has only a single proposal listed, then opening the invoice proposal is much faster, completing in under a sec, because the following is added to WHERE clause: (T1.PROPOSALID=@P1), thus querying for just a single invoice proposal.
Is it a practice to filter first before doing any selection, or is this something caused by custom code?
*This post is locked for comments
I have the same question (0)