How WhoKnew Views™ manages database storage, data aggregation, and query optimization
WhoKnew Views™ is engineered for database efficiency, even on high-traffic stores with thousands of products. The plugin uses smart data aggregation, tiered retention, and batch processing to minimize database load while maintaining years of historical data.
📊 Data Storage Architecture
WhoKnew Views™ uses a tiered storage system to balance data granularity with database performance:
📋
Days 0–90
Detailed Timestamps
Every individual view stored with exact timestamp
📦
Days 91–1,825
Daily Aggregates
Compressed to daily summaries (5-year history)
🗑️
After 5 Years
Rolling Window
Oldest data expires to prevent bloat
⚙️ Automatic Data Aggregation
A daily background job (WP-Cron) automatically compresses old data:
1
Daily Cron Job Runs
The wkv_daily_aggregation_job runs once per day to process view data.
2
Batch Processing (50 Products)
Products are processed in batches of 50 to avoid timeouts and memory issues.
3
Timestamps → Daily Counts
Views older than 90 days are compressed from individual timestamps to daily totals.
4
5-Year Rolling Window
Data older than 5 years is automatically removed, keeping the database lean.
✅ Works for All Users: Aggregation runs for both Free and Pro users—it’s a database maintenance feature, not a Pro feature. Pro users benefit from aggregated data for AI forecasting.
🗄️ Database Storage Locations
| Data Type | Storage Location | Key/Table |
|---|---|---|
| View Timestamps (90 days) | wp_postmeta | product_views |
| Daily Aggregates (5 years) | wp_postmeta | _wkv_daily_view_aggregates |
| Lifetime Views (permanent) | wp_postmeta | _wkv_total_real_views_ever |
| Plugin Settings | wp_options | whoknew_views_settings |
| Temporary Data | wp_options (transients) | _transient_wkv_* |
📈 Storage Efficiency Example
For a product with 1,000 views per day over 3 years:
❌ Without Aggregation
1,095,000
individual timestamp records
Each timestamp is ~10 bytes = ~10.5 MB per product
✅ With Aggregation
1,185
records (90 timestamps + 1,095 daily)
Each daily summary is ~20 bytes = ~25 KB per product
99.7%
Reduction in storage for historical data
🔍 Monitoring Database Health
Check your database performance in WhoKnew Views → System Info:
## MEMORY USAGE ##
Current Memory Usage: 45.25 MB
Peak Memory Usage: 52.00 MB
Memory Limit: 256M
## WORDPRESS ENVIRONMENT ##
WP Memory Limit: 256M
WP Max Memory Limit: 512M
## SERVER ENVIRONMENT ##
PHP Memory Limit: 256M
MySQL Version: 8.0.35
⚡ Performance Optimizations
WhoKnew Views™ includes several performance optimizations:
🔄
Transient Caching
Forecast data and settings are cached as transients to reduce database queries.
📦
Batch Processing
Aggregation and cleanup run in batches of 50 products to prevent timeouts.
🧹
Auto Cleanup
Expired transients and old data are automatically removed to prevent bloat.
⚡
Object Cache Compatible
Works with Redis/Memcached object caching for even faster option retrieval.
💡 Best Practices
- Keep WP-Cron running — Aggregation depends on daily cron jobs
- Use object caching — Redis or Memcached improves option retrieval speed
- Monitor memory usage — Check System Info if analytics are slow
- Regular backups — Include
wp_postmetaandwp_optionstables
✅ Zero Maintenance Required: The aggregation system runs automatically. No manual database optimization is needed—WhoKnew Views™ maintains itself.