i developing website on django & mysql similar linkedin in terms of complexity , functionality , expecting steep growth few months.
i have 1 question. while designing models , views, have 2 options. either go smaller number of database hits , handle bigger querysets(by making more complex queries & more joins) or handle smaller querysets thereby increasing number of database hits. example, when use prefetch_related() & select_related(), no. of database hits reduced significantly, size of querysets , no of joins performed on tables increase. 1 example.
so considering conditions under production, should prefer out of above two. little explanation better.
it better go smaller number of database hits because may bottleneck when performance critical.
having more hits hitting hard disk file every time want read line. of course final answer depends on frequency of usage , actual gains derive putting queries together. example, mean have cache data longer? how affect app if has same lots of users?
one way start off try , reduce number of query sets within same function - if 1 function doing 100 separate queries can better putting them together, if possible.
Comments
Post a Comment