Welcome Guest, Not a member yet? Register   Sign In
Best Practise
#1

[eluser]lachavvy[/eluser]
Hi all,

I'm quite new to Code Igniter. I'm looking to create a football website for a local 5 a side football league. The main functions are to show the different leagues going on, player profiles (showing their goals, and how their teams are doing etc).

I was wondering, what is the best practise for generating for the Goal Difference part of the table. I could store this in the database, but I could also do this on-the-fly using the "goals for" minus "goals against".

Is it, in most cases best to store things in databases if possible rather than have the web page process it every time as it may be more stressful for the web host?

Some insight into this will be very helpful, thanks!
#2

[eluser]mdvaldosta[/eluser]
If you can calculate it, don't save it in the database. That's just one more thing to worry with keeping updated and in sync when you're doing CRUD.
#3

[eluser]lachavvy[/eluser]
Thanks for the reply.

Would you still say the same if this calculation had to be done several times (20-30) per page load?

I assume this will become fairly server intensive if multiple people begin to view the site at the same time?
#4

[eluser]Peter Denk[/eluser]
I would say that it depends on how much traffic you expect to get.

Assuming that you anticipate a large amount of traffic you could store the Goal Difference and other calculated data in the database. You would then have to recalculate those numbers each time you insert a new game.
#5

[eluser]Rick Jolly[/eluser]
mdvaldosta is correct. I wouldn't complicate things with optimizations until necessary. Then, look for a better solution than denormalizing your database.
#6

[eluser]lachavvy[/eluser]
Brilliant, thanks guys.
#7

[eluser]JuanitoDelCielo[/eluser]
If you can calculate it, don’t save it in the database. Dont worry about the traffic dude if you need performance just user the cache library.
#8

[eluser]wh1tel1te[/eluser]
You should cache your results and regenerate them every, say, half an hour to an hour. That should keep results fresh enough without the big server load.




Theme © iAndrew 2016 - Forum software by © MyBB