0

Im working on a Django app, where in a user can search using a combination of parameters from 3 lists(say A, B and C). Total no. of searches possible = len(A)xlen(B)xlen(C).

For each search, a whole algorithm runs to bring data from the database, do some operations on it and finally come up with the context to be passed to the template. This takes a lot of time.

To reduce the query time, I'm thinking of creating static files (with names a+b+c), and run all queries to save the data in these files. So when the user searches for anything, instead of running the whole algo everytime, the context directly comes from these static data files.

What would be the best filetype to save this data in? Is it a good approach for reducing query time?

user_2000
  • 1,103
  • 3
  • 14
  • 26

1 Answers1

1

Unless your data are very big (> GB), use a caching system (redis, or memcached), through the Django cache framework : https://docs.djangoproject.com/en/dev/topics/cache/

jacquarg
  • 176
  • 1
  • 7
  • Thanks for the response! The thing is that the code for the algorithms alone comprises of 2000 lines, and by not querying it again for each query, I think I can save some time. Also, the data loaded in these files will keep changing everyday, dont know that if I use memcached, I'll be able to see changes reflected that often – user_2000 Jul 23 '13 at 19:29
  • You could do what you thought previously : pre-compute all the possible queries and keep the result in "static files". But the best "static files" format that I suggest for caching, is an in memory cahcing system (memcached, redis, ...) – jacquarg Jul 25 '13 at 15:28