3 ms·
Is there any good reason why you want to do computation like this with a database query, instead of, say, middle-ware? For the product (reduce #'* (select '
by mahmud 17y ago
Is there any good reason why you want to do computation like this with a database query, instead of, say, middle-ware?
For the product
(reduce #'* (select 'value :from 'product :flatp t))
If you want the sum change #'* to #'+.
- garethm 17y agoIf you do it in the database, you don't have to shunt all the values across the wire from the database server. If the middle tier is on a different machine, this can make a significant difference to the time taken to do the query.
- mahmud 17y agogood point, but as engineering trade offs go; do you want to tie your application's performance to one RDBMS' non-standard hacks; or do you want to throw cheap hardware, ram, fat pipes and caches at the problem? I can scale my lousy middleware-as-calculator solution with something as cheap as running data consumers and producers on the same machine, or as "expensive" as a gigabit switch and a fat cable. What would you gain from a beefy RDBMS that you couldn't get done with sharded db wisely spread across machines?