Opened 9 years ago
Closed 9 years ago
#1471 closed defect (fixed)
Packing dataviews too slow on SQL Server 2016
| Reported by: | Kurt Endress | Owned by: | Kurt Endress |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | Dataviews (CT) | Version: | N/A |
| Severity: | Keywords: | ||
| Cc: | Database Engine: | SQL Server | |
| Operating System: | N/A |
Description
The report dataviews order_packing2 and order_packing_nsgc often time out when used with the new SQL Server 2016 database. This seems to be due to the new optimizer with 2014 as it still works in 2012 compatibility mode.
Change History (2)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Placed on production 7/1/2017 and included in 1.9.9.2 build
Note:
See TracTickets
for help on using tickets.

Changes made to the two packing report dataviews. They work under 2016. Loaded on npgsdev for additional testing.
order_packing_nsgc_20170504.dataview
order_packing2_20170504.dataview
Change details follow.
This was the sub-select join I replaced:
) list ON oi.order_request_item_id = list.order_request_item_id
With this:
WHERE oi.order_request_id IN (:orderrequestid)
Simplifying that makes the optimizer work for these two dataviews without adding an index to the database. That looks like a clear win for simplification, but to get it to support two id parameters I had to duplicate the other 147 lines of SQL into a separate UNION SELECT statement with a where on the item ids. Avoiding multiple copies of large select blocks was the reason I switched to the sub-select join of parameters. But in this case it seems to confuse the optimizer
I also made a slight change to a sub-select that pulled taxonomic usage restriction when I noticed it was slowing down large orders:
Simplified to:
The idea is to find tax use notes the accession’s taxon and also for synonyms of the taxon. I supplied the original to Karen from John’s notes on how he did it in Oracle. But looking at the code again I realized I could get rid of the OR and get the same result.