Models vs performance

Hello,

I'm using Metabase 1.47.9, connected to MongoDB.
I have currently a dashboard containing 7 questions, all written as native queries. 5 of them require some "heavy" workload resulting in the fact that when I open the dashboard it takes a few second before everything is displayed. When I open each question individually, the response time is lower (< 1sec).

For those 5 heaviest queries, a big part of the code is actually the same. So I was thinking of putting all the common stuff into a model. But I'm wondering one thing : if I do that, will the code of my model be executed only once when opening the dashboard, or will it be executed for each query anyway ?

If it's executed only once it could drastically reduce the display time.

Sub-question : when I have a model, I see that I can use it as input for a new question done with the UI editor, but not for a new native query (on Mongo). Is this feature planned in a near future ?

@nguilite Centralizing the logic into a core model and caching the result set should have an impact. These articles area good starting point for understanding how caching works in metabase:

  1. Caching in Metabase
  2. My Dashboard is Slow
  3. Model Caching

On referencing Mongo models in native queries - I'm afraid don't know the answer to that right now but I'll see if I can find out!

@nguilite supporting the reference of models & saved questions written in Mongo is not currently on the roadmap. A feature request has been created: Ability to Reference Models & Saved Questions Written in MongoDB · Issue #38341 · metabase/metabase · GitHub

Please upvote the request and add any additional notes or context you may have.