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

Show Name - combine lookups for classification links #1784

Merged
merged 14 commits into from
Jan 23, 2024
Merged

Conversation

nimmolo
Copy link
Contributor

@nimmolo nimmolo commented Jan 9, 2024

The "Classification" panel does 14 separate lookups of Names to show the links to the "parent" taxonomies. It costs the page about a second of load time.

  Name Exists? (27.6ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Grifola') LIMIT 1
  Name Load (85.4ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Grifola')
  Name Exists? (26.4ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Meripilaceae') LIMIT 1
  Name Load (86.9ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Meripilaceae')
  Name Exists? (26.9ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Polyporales') LIMIT 1
  Name Load (87.6ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Polyporales')
  Name Exists? (26.8ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Agaricomycetes') LIMIT 1
  Name Load (83.9ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Agaricomycetes')
  Name Exists? (26.2ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Basidiomycota') LIMIT 1
  Name Load (85.7ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Basidiomycota')
  Name Exists? (26.1ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Fungi') LIMIT 1
  Name Load (85.5ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Fungi')
  Name Exists? (6.9ms)  SELECT 1 AS one FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Eukarya') LIMIT 1
  Name Load (20.3ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`search_name` = 'Eukarya') ORDER BY `names`.`id` ASC LIMIT 1
  CACHE Name Load (0.0ms)  SELECT `names`.* FROM `names` WHERE (`names`.`correct_spelling_id` IS NULL) AND (`names`.`text_name` = 'Grifola')
  Rendered controllers/names/show/_classification.html.erb (Duration: 718.5ms | Allocations: 5946)

Those lookups seem like they could be consolidated into a single mother query, with the names derived from that query.

This reduces load time for the Classification partial from 768ms to 207ms locally, a 73% savings.

@nimmolo nimmolo changed the base branch from nimmo-name-observations-menu to main January 9, 2024 21:42
@nimmolo nimmolo marked this pull request as ready for review January 23, 2024 02:32
@nimmolo nimmolo requested a review from JoeCohen January 23, 2024 02:33
@nimmolo nimmolo merged commit 291021c into main Jan 23, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant