Requirements: MODORDERS-488 Investigate transition of Orders search to cross-index subqueries
Overview:
Endpoints calling views:
/orders-storage/receiving-history → receiving_history_view
Receiving view totally differs from other views. It is totaly builded on the fly and don has any own tables for persisting data. It could be switched to the cross index approach, but in this case instead of single database request there will be 3 requests which will return a large amount of data (collections of pieces, order lines and purchase orders). Making multiple requests and processing such large amount of data (which might be containing hundreds of elements withing each collection) wil not give any perfomance improvement.
/orders-storage/orders → orders_view
/orders-storage/po-lines → po_lines_view
/orders-storage/order-lines → order_lines_view
Prepared a POC with migration of this endpoint from searching accross the views to the searching via cross-indexes
Performance improvements:
For the perfomance testing purposes I have prepared data loading script which creates 100 purchase orders and 50.000 PO lines in total. Each poline slightly differs from other only by listUnitPrice, so search requests will be performed quering this field by value.
Results of the search across the views:
Query example /orders-storage/order-lines?query=workflowStatus==Pending and cost.listUnitPrice==21.0
As you can see every search requests takes almost 2 seconds
Results of the search via cross index approach:
Query example differs a bit according to cross index syntax: /orders-storage/order-lines?query=purchaseOrder.workflowStatus==Pending and cost.listUnitPrice==21.0
As you can see every search requests takes less than 200 ms
So switching implementation from views to the cross index search improves perfomance about 10 times.