gingeard opened a new issue, #24281:
URL: https://github.com/apache/superset/issues/24281

   Using Custom SQL in the Row/Column section significantly increases the time 
required to generate a chart compared to using the same SQL expressions in 
Calculated Columns.
   
   The simplest way to check the duration of a query generation is to click on 
the three dots at the top right and select "View query." Below are described 
two scenarios: one where query generation in chart is very slow (Scenario A) 
and another where it is instantaneous (Scenario B). 
   
   #### How to reproduce the bug
   
   Scenario A (time-consuming):
   
   1. Go to Charts -> + Chart -> 1). Choose any dataset with a date column. 2). 
Pivot Table -> Create New Chart
   2. Set the Query modal settings as follows:
   3. Columns -> Custom SQL: DATE_TRUNC(column_with_some_date, QUARTER)
   4. Metrics -> any, for example, COUNT(*)
   5. Click on Update Chart
   6. See unexpected behavior that the chart will be created 15-20 seconds 
slower. It also could be checked by pressing three dots at the top right corner 
of the chart and clicking View query. The modal window with the query will be 
shown NOT immediately.
   
   ### Expected results
   
   A chart creating quickly. The modal window with the query shows immediately.
   
   ### Actual results
   
   Additional 15-20 seconds of waiting. The modal window with the query hasn't 
shown immediately.
   
   ### Workaround:
   
   I'm able to build the identical chart but will work much quicker as 
following steps:
   
   Scenario B (quick): 
   
   1. The same: Go to Charts -> + Chart -> 1). Choose any dataset with a date 
column. 2). Pivot Table -> Create New Chart
   2. Go to Chart Source -> Three dots -> Edit dataset
   3. Open the tab Calculated columns
   7. Add item with name quarter_date and SQL Expression: 
DATE_TRUNC(column_with_some_date, QUARTER)
   8. Set the Query modal settings as follows:
   9. Columns -> Saved -> Saved expressions -> column_with_quarter
   10. Metrics -> any, for example, COUNT(*)
   11. Click on Update Chart
   12. See that the chart will be created quickly. It also could be checked by 
pressing three dots at the top right corner of the chart and clicking View 
query. The modal with the query will be shown immediately.
   
   #### Screenshots
   
   Scenario A (time-consuming): With custom SQL as Column/Row (23 sec):
   
   <img width="1313" alt="image" 
src="https://github.com/apache/superset/assets/7454811/b91c897a-1760-448a-b0c8-5528a549ad5c";>
   
   Scenario B (quick): With Calculated Column with the same SQL expression (6 
sec):
   
   <img width="1313" alt="image" 
src="https://github.com/apache/superset/assets/7454811/f8e53044-d501-421e-bdfd-0638433ed2c1";>
   
   Also we can check that produced SQL query is the same:
   
   Scenario A (time-consuming):
   
   <img width="1175" alt="image" 
src="https://github.com/apache/superset/assets/7454811/964db948-3ec6-447c-a54c-c77152a6fa93";>
   
   Scenario B (quick):
   
   <img width="1183" alt="image" 
src="https://github.com/apache/superset/assets/7454811/eb13c697-a9fc-4b5a-ac28-726e0bb519f0";>
   
   ### Environment
   
   - browser type and version: Google Chrome Version 113.0.5672.126 (Official 
Build) (arm64)
   - superset version: 2.1.0
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to