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

[sql_lab] Improve performance, only use slow func when needed #9612

Merged
merged 1 commit into from Apr 23, 2020

Conversation

dpgaspar
Copy link
Member

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

When quering the examples table wb_health_population on SQLLab including all the columns on the statement:

SELECT "NY_GNP_PCAP_CD",
       "SE_ADT_1524_LT_FM_ZS",
       "SE_ADT_1524_LT_MA_ZS",
       "SE_ADT_1524_LT_ZS",
       "SE_ADT_LITR_FE_ZS",
  ... (8551 characters truncated) ... _IN_ZS",
       "SP_UWT_TFRT",
       country_code,
       country_name,
       region,
       year
FROM public.wb_health_population

The query would take approximately 50s to 70s to complete, yet the query itself only takes 10-20ms to execute. This is due to ParsedQuery.__extract_from_token function that extracts all the tables from a query, noticed that the property tables itself is seldom used/needed. This is a simple fix, that reduces the time to execute from 50s-70s to 10s-20s so 1/6 of the total time.

Expected, since sql_json execution path instantiates ParsedQuery 6 times.

Simple fix, but the __extract_from_token recursive loop should be visited and improved (@lilykuang).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@robdiciuccio @willbarrett

@dpgaspar dpgaspar marked this pull request as ready for review April 22, 2020 12:34
@dpgaspar dpgaspar requested a review from villebro April 22, 2020 12:34
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow 👀 Nice improvement, would be great to get that __extract_from_token method refactored, I can't imagine it needs to take that long..!

Copy link
Member

@willbarrett willbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for finding + fixing this @dpgaspar

@villebro - we have someone on it. That function will get some attention in the near future.

@dpgaspar dpgaspar merged commit 76764ac into apache:master Apr 23, 2020
@dpgaspar dpgaspar deleted the fix/slow-queries branch April 23, 2020 08:36
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants