ScenarioI am working on a web application that handles financial transactions, and my code will need to be reusable for everything from consumer carts to manufacturer/distributor shipments. The project uses Laravel in a fairly typical LAMP environment.I can use PHP's BCMath functions or MySQL queries to handle math operations, but the Eloquent ORM tends to create a lot of queries and db transactions, so I am unsure which will be better. I will need to do addition, subtraction, multiplication, and division with precision up to a the equivalent of a MySQL DECIMAL(10,4).Question 1: performanceWhich will have better performance for precision maths: MySQL queries or BCMath? The answer should include considerations for network overhead. MySQL is running on a Rackspace 8GB standard instance (8GB ram, 4 vCPUs, 600 Mbps, 320GB SSD); the PHP server is running on a Rackspace 2GB standard instance (2GB ram, 2 vCPUs, 240 Mbps, 80GB SSD). Server setup is adaptable, and there is a high likelihood of moving to Azure or AWS before or just after launch. The main reason that the MySQL server has better specs is that we were doing some big data analysis (multiple worker servers, 1 db) last year and still have large storage requirements.Question 2: philosophyIf one is better than the other, does it make sense to worry about optimization during such an early stage of development (core functionality is still lacking), or is it better to just use whatever is convenient and optimize later?
BCMath vs MySQL: performance
php;performance;mysql;math;numeric precision