I am working on an executing company, and we need to pack and send many orders from the warehouse to our customers. To increase efficiency, we would like to group identical orders and pack them most optimally. By identical, I mean the presence of the same number of order lines containing the same SKUs and the same ordinal values.
To achieve this, I thought about hashing each order. Then we can group the hash to quickly see which orders are the same.
We are moving from the Access database to the PostgreSQL database, and we have .NET-based systems for loading data and a general order processing system, so we can either hash during data loading or transfer this task to the database.
First, my question is, should the hash be managed by the database, possibly with triggers, or if the hash will be created on the fly using a view or something else?
And secondly, it would be better to calculate the hash for each order line, and then combine them to find the hash of the order hash for grouping, or I just have to use a trigger for all CRUD operations in the order line table, - calculates a single hash for the entire order and stores the value in the order table?
TIA
source share