3 ms·
I wrote a basic bitcoin exchange using triggers and PL/pgSQL back in 2012. You would insert into an orders table and an after-insert trigger would run the order
by mifreewil 8y ago
I wrote a basic bitcoin exchange using triggers and PL/pgSQL back in 2012. You would insert into an orders table and an after-insert trigger would run the order matching algo written in a PL/pgSQL function. It wouldn't have scaled up too well, I suspect, but it worked really well for the initial product that allowed us to acquire initial customers and raise a Series A.
I would say my experience was pretty positive, I would consider doing something like this again for the right use case. It saved a lot of back-and-forth queries between the app and database and allowed the logic in the app to be much more simple than it otherwise would have been, but at the cost of insert throughput into the triggered tables.
If you are at all considering this route, I would recommend the excellent project, pgtap, for testing: https://pgtap.org/ https://pgtap.org/
I used pgtap, along with the cli utility, pgprove, to run tests.