Tuesday, February 07, 2006

Menu tweaking (less hits against the database)

Today I was optimizing the database access from the left menu: the menu is showing a list of languages and pairs of languages and it should change if a new lesson with a new language is added or lesson is deleted or lesson is shared or lesson is unshared or user loggs in or user loggs out. So you can imagine why it was hitting the database every time the page gets reloaded, even for static pages like Home of "Dictinary" articles.

What I did is placed a system of flags that force the database hit only in cases I described above but if nothing is changed then the menu is constructed from the http session. Of course this solution prones to less scalability if there is a huge number of people but for the begginning let's have it this way. In the future it's better to rely more on the database.

No comments: