I am working on a CakePHP application at the moment and I am writing a few validation rules for one of the models.
I have a feeling I am making too many checks to the database at the moment and want to get a view on this.
For example I am saving to a model which has a lot of associated models as such I am saving 5 different foreign id’s per save operation. To ensure that all of the id’s are correct I have a validation rule for each which checks that in fact the ID does exist in the correct table in the database.
There are also a few other validation rules, but without going in to too much detail I think I am hitting the database around 10 times for one save operation, to ensure that all of the data is valid.
Is there any sort of limit I should be applying, or is the overhead fairly minimal?
Thanks
Premature optimization is the root of all evil.
Get your app rolled out. Once real people use it for real purposes, you can do benchmarks to see where you really need to optimize.