Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-3977

Cache database tables with different strategies

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0.0
    • 3.9.5
    • Performance
    • Hide

      Database optimizations can be configured with two parameters: cachingStrategy (eager, lazy, none) and debug (whether to log database usage or not). Each database table has its own default configuration, but these can be overriden using the following config entries:

      • databaseOptimizations will override the default configuration for all tables in the app.
      • databaseTableOptimizations will override the default configuration for specific tables in the app.

      At the moment, only 3 tables support optimizations: wscache_2, filepool_files and core_config.

      For example, the following configuration can be used to enable debugging in all tables and forcing the wscache_2 table to use eager caching:

      {
      	"databaseOptimizations": { "debug": true },
      	"databaseTableOptimizations": {
      		"wscache_2": { "cachingStrategy": "eager" }
      	}
      }
      

      Show
      Database optimizations can be configured with two parameters: cachingStrategy (eager, lazy, none) and debug (whether to log database usage or not). Each database table has its own default configuration, but these can be overriden using the following config entries: databaseOptimizations will override the default configuration for all tables in the app. databaseTableOptimizations will override the default configuration for specific tables in the app. At the moment, only 3 tables support optimizations: wscache_2 , filepool_files and core_config . For example, the following configuration can be used to enable debugging in all tables and forcing the wscache_2 table to use eager caching: { "databaseOptimizations": { "debug": true }, "databaseTableOptimizations": { "wscache_2": { "cachingStrategy": "eager" } } }
    • MOODLE_39_STABLE
    • MOODLE_400_STABLE
    • Moodle App 4.0

      In MOBILE-3971 we introduced a new pattern to cache database tables in memory in order to speed up reads. After some investigation, we've seen that this approach won't be optimal in all the tables. For example, some tables have too many rows and the memory usage would be to high. Or some other tables don't make as many reads.

      However, it's not completely clear what's the best caching strategy for each table without doing some real-life testing. Also, this could potentially become an issue in production. For that reason, we've decided to make database caching strategies configurable both on the entire app and on a per-table basis. This should be configurable with an entry in the config.json file.

      In particular, we can create a database table manager that proxies database interactions through a cache following one of these strategies:

      • Eager caching (what is already implemented in the config table, caching the entire table).
      • Lazy caching (this would cache rows after being read once).
      • No caching (this would just execute all the queries in the database without using any cache).

      One candidate for using lazy caching is the filepool_files table. And the ws_cache_2 table will probably use no caching. The core_config table can continue using eager caching. So we can start by implementing the different strategies in these 3 tables.

            jleyva Juan Leyva
            noeldemartin Noel De Martin
            Dani Palou Dani Palou
            Juan Leyva Juan Leyva
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.