'How would you setup a data store to use C# to analyze historical transactions to perform new transactions in Azure?
We have an Azure SQL Database that houses our transactional system for orders. Each order is assigned to a different vendor based upon the geographic area that the order is located.
I want to build a system in C# that analyzes the historical orders to see which vendors have the best performance for the geo location of a new order to be able to programmatically assign new orders to a vendor based upon the vendors overall ranking. The main component of determining which historical orders to include in the analysis is the geographic location.
I'm utilizing SQL Server Geography data type to create a buffer or radius around the geography to determine which orders to include in the historical analysis for each new order. The procedure takes the parameters @OrderGeoLocation GEOGRAPHY, @OrderStartDate DATETIME, @OrderEndDate DATETIME
DECLARE @RadiusArea GEOGRAPHY
SELECT @RadiusArea = @OrderGeoLocation.STBuffer(@RadiusDistanceInMeters)
SELECT DISTINCT
o.Id,
o.OrderDate,
o.VendorId,
o.VendorName,
o.OrderStatusStatic,
o.AssignedDateTime,
o.AcceptedDateTime,
o.DeclinedDateTime,
o.CompletedDateTime
INTO #ForwardedCaseHistory
FROM vwOrders o WITH(NOLOCK)
JOIN vwOrderAddresses oa WITH(NOLOCK) ON oa.Id = fc.Id
WHERE o.OrderDate Between @OrderDateStart AND @OrderDateEnd
AND oa.GeoGeography.STIntersects(@RadiusArea) = 1
If the returned result set doesn't contain a certain threshold of orders, I go out further with the radius and or time. As you can imagine... this is very intense on the database and is beginning to degrade performance of the system overall. The historical order data isn't required to be live... It would be fine if it were up to 12 hours old. But I still need to be able to run stored procedures against it to retrieve the orders. I've thought about just setting up a replication scheme to bring it to another instance of a SQL Database. That would work... but I'm not convinced it's the best way. What are your thoughts on how you would do it?
Thoughts?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
