erlang - Mnesia fold over records, referencing a second table -


i have schema this:

-record(sale, {   id,   price,   tax,   sku,   datetime })  -record(refund, {   id,   sale_id,   datetime }) 

there 600,000 records in sale table , 20,000 in refund table.

i need fold on data in sales table, grouping each sku amount received (price) , amount refunded (by checking #refund.sale_id).

is there efficient way mnesia, avoid n+1 query problem each sale in fold operation, need make second call mnesia see if refund exists? way of doing naive join?

is sale table ordered_set? if yes, can merge join usual. first refund , sort them sale_id. fold on sale , accumulate dict or ets sku key.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -