I’m working on a Cube.js project where I need to configure pre-aggregations to refresh at regular intervals, specifically every 12 hours or at a specific time like 4:00 AM UTC. I’ve set up a cube to optimize query performance using pre-aggregations, but I’m unsure how to configure the refresh schedule to achieve this behavior.
When testing the last refresh using Postman, for example, checking every 5 minutes, Cube.js doesn’t seem to respect the scheduled refresh time, even though I’ve set it for every 5 minutes. The refresh happens inconsistently.
Here’s an example of my Orders cube where I want to apply these configurations:
cube('Orders', {
sql: `SELECT id, user_id, total_price, added_at FROM public.orders`,
preAggregations: {
OrdersSummary: {
dimensions: [Orders.id, Orders.userId, Orders.totalPrice],
refreshKey: {
every: '12 hour'
}
},
OrdersDetails: {
dimensions: [Orders.id, Orders.userId, Orders.addedAt],
refreshKey: {
every: '12 hour'
}
}
},
dimensions: {
id: {
sql: `id`,
type: `number`,
primaryKey: true
},
userId: {
sql: `user_id`,
type: `number`
},
totalPrice: {
sql: `total_price`,
type: `number`
},
addedAt: {
sql: `added_at`,
type: `time`
}
}
});