rusackas commented on code in PR #42953:
URL: https://github.com/apache/superset/pull/42953#discussion_r3746773906


##########
docs/admin_docs/configuration/cache.mdx:
##########
@@ -134,6 +134,43 @@ CELERY_CONFIG = CustomCeleryConfig
 This will cache the top 5 most popular dashboards every hour. For other
 strategies, check the `superset/tasks/cache.py` file.
 
+### Warming Up Native Filter Options
+
+Native filter Value-type dropdown option queries (e.g. `SELECT DISTINCT column 
FROM table`) are
+cached the same way as chart data, via `DATA_CACHE_CONFIG`. However, the 
strategies above only warm
+up chart render queries, so the first user to open a dashboard's filter 
dropdown after a cache entry
+expires still triggers a fresh database query.
+
+The `native_filter_options` strategy pre-populates the cache for these 
dropdown queries. It reads
+each dashboard's `native_filter_configuration`, builds the same 
`filter_select` chart-data query the
+frontend would send, and executes it as the configured 
`SUPERSET_CACHE_WARMUP_USER`:
+
+```python
+class CustomCeleryConfig(CeleryConfig):
+    beat_schedule = {
+        **CeleryConfig.beat_schedule,
+        'cache-warmup-native-filters': {
+            'task': 'cache-warmup',
+            'schedule': crontab(minute=0, hour=3),  # daily at 03:00

Review Comment:
   Good catch — added a note that the schedule needs to be at least as frequent 
as the effective native filter cache TTL, since the daily example only makes 
sense for TTLs of a day or more.



##########
docs/admin_docs/configuration/cache.mdx:
##########
@@ -134,6 +134,43 @@ CELERY_CONFIG = CustomCeleryConfig
 This will cache the top 5 most popular dashboards every hour. For other
 strategies, check the `superset/tasks/cache.py` file.
 
+### Warming Up Native Filter Options
+
+Native filter Value-type dropdown option queries (e.g. `SELECT DISTINCT column 
FROM table`) are
+cached the same way as chart data, via `DATA_CACHE_CONFIG`. However, the 
strategies above only warm
+up chart render queries, so the first user to open a dashboard's filter 
dropdown after a cache entry
+expires still triggers a fresh database query.
+
+The `native_filter_options` strategy pre-populates the cache for these 
dropdown queries. It reads
+each dashboard's `native_filter_configuration`, builds the same 
`filter_select` chart-data query the
+frontend would send, and executes it as the configured 
`SUPERSET_CACHE_WARMUP_USER`:
+
+```python
+class CustomCeleryConfig(CeleryConfig):
+    beat_schedule = {
+        **CeleryConfig.beat_schedule,
+        'cache-warmup-native-filters': {
+            'task': 'cache-warmup',
+            'schedule': crontab(minute=0, hour=3),  # daily at 03:00
+            'kwargs': {
+                'strategy_name': 'native_filter_options',
+                'dashboard_ids': [1, 2, 3],
+            },
+        },
+    }
+```
+
+Requirements and limitations:
+
+- `SUPERSET_CACHE_WARMUP_USER` must be set to a user with access to the 
dashboards and datasets
+  referenced by the native filters.
+- `DATA_CACHE_CONFIG` must be configured (Redis recommended).

Review Comment:
   Fair point — the default `NullCache` and 
`NATIVE_FILTER_OPTIONS_CACHE_TIMEOUT = -1` both silently no-op the warm-up. 
Called both out explicitly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to