grafana / clickhouse-datasource

Grafana Plugin for ClickHouse
Apache License 2.0
135 stars 62 forks source link

Do not re-fetch table metada on adding a new filter #415

Open mshustov opened 1 year ago

mshustov commented 1 year ago

What happened: Whenever I add an ad-hoc filter for a panel, the plugin makes a request SELECT name, type, table FROM system.columns, which adds a few sec. delay.

What you expected to happen: Do not fetch definitions again, if the plugin already has the necessary data.

How to reproduce it (as minimally and precisely as possible):

  1. Crete a panel
  2. add an ad-hoc filter variable
  3. add a filter
  4. add another filter

Screenshots 2023-06-04_14-45-28

Environment:

aangelisc commented 1 year ago

Hi @mshustov, thank you for opening this. I'm unsure this is a bug, how can we be certain that the schema hasn't changed in between the filters being added? If a datasource is left open for awhile that could be enough time for the schema to change and those changes would not be reflected in the options.

mshustov commented 1 year ago

how can we be certain that the schema hasn't changed in between the filters being added? If a datasource is left open for awhile that could be enough time for the schema to change and those changes would not be reflected in the options.

The plugin can implement time-based or any other caching policy. I don't think the plugin re-fetches data on Expore view for example, and it provides a way better UX.

bossinc commented 1 year ago

I think it makes sense to cache the schema for the session on the frontend. It would make a better user experience