It's not you - my CPU says yes, but my database say no
November 16, 2007 6:54 PM
Subscribe
How many database reads/writes are okay per web page view? Also, what is better, big tables or lots of join tables?
I'm starting out in Web based development after years of C++, and this is the one topic I cannot seem to find a lot of information on.
When I have a database in the back end, I will need to read and write data to this database. Each page-open for each user will need to query the database. What is excessive, and what is good? Is 10 individual queries per page open too much? Is 100 too much? If I am only transfering small amounts of data, does it make a difference?
Let's say for example I have a user name, and I need to get some information about him whenever he logs in - say for example, his article view count. This changes every time he opens the page, and needs to be persisted in the database. Do I read and write to the database for every page open?
This is assuming no-caching.
The second part of the question - is it better to have lots of tables storing small amounts of data which are linked to each other using relationship ids, or is it better to use single tables with lots of columns? Which is more efficient?
And finally, in this example, what is better practise:
If I have 10 items in a database, and I need to associate the 10 items with 10 other values from the same database. Is it better to query the 1st item from the db, then query the matching item, and associate them? Or would it be better to query 10 of the first item at once, then 10 of the second item at once, then use a double loop to associate them? The first is heavy on database, the second is heavy on CPU. What is more scalable in the large scale?
posted by markovich to technology (13 comments total)
4 users marked this as a favorite
It's all dependent. It depends on the server, on the kind of pages being created, on the expected traffic patterns, on the required performance, and on a lot of other things like that.
No one can possibly answer your question.
posted by Steven C. Den Beste at 7:23 PM on November 16, 2007