Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search: navigation bar search very slow for non-admins #69659

Closed
csquire opened this issue Jun 6, 2023 · 12 comments · Fixed by #88019
Closed

Search: navigation bar search very slow for non-admins #69659

csquire opened this issue Jun 6, 2023 · 12 comments · Fixed by #88019
Labels
area/search needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating type/bug type/performance

Comments

@csquire
Copy link

csquire commented Jun 6, 2023

What went wrong?

What happened:
After upgrading our grafana instance from 9.4 to 9.5.2, users have started reporting slowness when searching via the new nav bar. Searches are typically taking 12 seconds or longer for both authenticated and non-authenticated users. For authenticated administrators, nav bar searches perform very quickly though.

Searching from the dashboard search page seems fine though. We don't currently have slow query logs enabled on our database.

The below issue seems similar, but our database appears to have the index that was added as the resolution.
#25688

Our system has about:

  • 4200 dashoards
  • 650 users

What did you expect to happen:
I expect searches using the nav bar to be performant when non-admins search.

How do we reproduce it?

Step 1:

  • Click in the top nav bar and start typing a search while unauthenticated

Step 2:

  • Wait for the search request to complete and update the results

grafana_query

What Grafana version are you using?

v9.5.2 (cfcea75)

Optional Questions:

Is the bug inside a Dashboard Panel?

Copy the panel's "get-help" data here

Grafana Platform?

Kubernetes

User's OS?

No response

User's Browser?

Chrome, Firefox and Edge all act the same

Is this a Regression?

None

Are Datasources involved?

No response

Anything else to add?

No response

@torkelo
Copy link
Member

torkelo commented Jun 6, 2023

@csquire do you have any feature toggles enabled? for example panelTitleSearch?

@torkelo torkelo added type/bug area/search type/performance needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating labels Jun 6, 2023
@csquire
Copy link
Author

csquire commented Jun 6, 2023

No feature toggles are enabled in our config, we are just using defaults.

@baosenle
Copy link

We also encountered the same problem, after upgrading our grafana instance from 9.1.7 to 9.5.2, searches are typically taking 30 seconds or longer for non-admins.

Our system has about:

  • 4500 dashoards
  • 5000 users
  • 110000 permission

Slow query sql:
SELECT dashboard.id, dashboard.uid, dashboard.title, dashboard.slug, dashboard_tag.term, dashboard.is_folder, dashboard.folder_id, folder.uid AS folder_uid, folder.slug AS folder_slug, folder.title AS folder_title FROM ( SELECT dashboard.id FROM dashboard WHERE ((dashboard.uid IN (SELECT substr(scope, 16) FROM permission WHERE scope LIKE 'dashboards:uid:%' AND role_id IN(SELECT id FROM role INNER JOIN ( SELECT ur.role_id FROM user_role AS ur WHERE ur.user_id = 5087 AND (ur.org_id = 1 OR ur.org_id = 0) UNION SELECT br.role_id FROM builtin_role AS br WHERE br.role IN ('Viewer') AND (br.org_id = 1 OR br.org_id = 0) ) as all_role ON role.id = all_role.role_id) AND action = 'dashboards:read') AND NOT dashboard.is_folder) OR (dashboard.folder_id IN (SELECT id FROM dashboard as d WHERE d.uid IN (SELECT substr(scope, 13) FROM permission WHERE scope LIKE 'folders:uid:%' AND role_id IN(SELECT id FROM role INNER JOIN ( SELECT ur.role_id FROM user_role AS ur WHERE ur.user_id = 5087 AND (ur.org_id = 1 OR ur.org_id = 0) UNION SELECT br.role_id FROM builtin_role AS br WHERE br.role IN ('Viewer') AND (br.org_id = 1 OR br.org_id = 0) ) as all_role ON role.id = all_role.role_id) AND action = 'dashboards:read')) AND NOT dashboard.is_folder) OR (dashboard.uid IN (SELECT substr(scope, 13) FROM permission WHERE scope LIKE 'folders:uid:%' AND role_id IN(SELECT id FROM role INNER JOIN ( SELECT ur.role_id FROM user_role AS ur WHERE ur.user_id = 5087 AND (ur.org_id = 1 OR ur.org_id = 0) UNION SELECT br.role_id FROM builtin_role AS br WHERE br.role IN ('Viewer') AND (br.org_id = 1 OR br.org_id = 0) ) as all_role ON role.id = all_role.role_id) AND action = 'folders:read') AND dashboard.is_folder)) AND dashboard.org_id=1 AND dashboard.title LIKE '%ba%' ORDER BY dashboard.title ASC LIMIT 100 OFFSET 0) AS ids INNER JOIN dashboard ON ids.id = dashboard.id LEFT OUTER JOIN dashboard AS folder ON folder.id = dashboard.folder_id LEFT OUTER JOIN dashboard_tag ON dashboard.id = dashboard_tag.dashboard_id ORDER BY dashboard.title ASC

@torkelo @papagian @Graham-Moreno

@xmm1989218
Copy link

any progress?we also meet same problem.

@aishyandapalli
Copy link
Contributor

We have the same problem too. Any progress?

@kalleep
Copy link
Contributor

kalleep commented Aug 21, 2023

What database are you using for grafana? Based on benchmarks the query is performing bad on mysql 5.7 but has no problem on on either postgres 12+ , mysql 8 or sqlite.

Benchmarks is running with around 80k dashboards and 500k permissions. We are not sure we will do any fixes to mysql 5.7 due to it being EOL soon.

If you are using any other database could you please provide that you are using?

@xmm1989218
Copy link

What database are you using for grafana? Based on benchmarks the query is performing bad on mysql 5.7 but has no problem on on either postgres 12+ , mysql 8 or sqlite.

Benchmarks is running with around 80k dashboards and 500k permissions. We are not sure we will do any fixes to mysql 5.7 due to it being EOL soon.

If you are using any other database could you please provide that you are using?

mariadb10.1

@aishyandapalli
Copy link
Contributor

We are facing the same issue with MySQL v8

@csquire
Copy link
Author

csquire commented Aug 28, 2023

We are on MySQL 5.7. A quick test in our staging environment did show improvement when upgrading to MySQL 8, so we'll schedule an upgrade to the production database and see if it helps.

@aishyandapalli
Copy link
Contributor

Apologies, we are also on MySQL v5.7

@knuzhdin
Copy link
Contributor

knuzhdin commented Oct 24, 2023

I have the same issue on 10.1.5 grafana. Backend is MySQLv8 (8.0.31-23 Percona Server)
admin:non-admin search times ratio is between 1:40 to 1:timeout (i.e. over 2 min)

@sjoeboo
Copy link

sjoeboo commented Mar 8, 2024

Also seeing this. Just promoted a user who was seeing 20s latency on searches to admin and they immediatly went down to what I as admin see of sub 100ms latencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/search needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating type/bug type/performance
Projects
None yet
8 participants