官术网_书友最值得收藏!

  • Learning Tableau 2020
  • Joshua N. Milligan
  • 500字
  • 2021-06-11 18:31:01

Performance considerations

When working with a small dataset and an efficient database, you often won't notice inefficient calculations. With larger datasets, the efficiency of your calculations can start to make a difference to the speed at which a view is rendered.

Here are some tips for making your calculations as efficient as possible:

  • Boolean and numeric calculations are much faster than string calculations. If possible, avoid string manipulation and use aliasing or formatting to provide user-friendly labels. For example, don't write the following code: IF [value] == 1 THEN "Yes" ELSE "No" END. Instead, simply write [value] == 1, and then edit the aliases of the field and set True to Yes and False to No.
  • Look for ways to increase the efficiency of a calculation. If you find yourself writing a long IF ELSEIF statement with lots of conditions, see whether there are one or two conditions that you can check first to eliminate the checks of all the other conditions. For example, let's consider simplifying the following code:
    //This is potentially less efficient...
    IF [Type] = "Dog" AND [Age] < 1 THEN "Puppy" 
    ELSEIF [Type] = "Cat" AND [Age] < 1 THEN "Kitten" 
    END
    //...than this code:
    IF [Age] < 1 THEN
        IF [Type] = "Dog" THEN "Puppy"
        ELSEIF [Type] = "Cat" THEN "Kitten"
        END
    END 
    

    Notice how the check of type doesn't have to be done for any records where the age was less than 1. That could be a very high percentage of records in the dataset.

  • Row-level calculations have to be performed for every row of data. Try to minimize the complexity of row-level calculations. However, if that is not possible or doesn't solve a performance issue, consider the final option.
  • When you create a data extract, certain row-level calculations are materialized. This means that the calculation is performed once when the extract is created, and the results are then stored in the extract. This means that the data engine does not have to execute the calculation over and over. Instead, the value is simply read from the extract. Calculations that use any user functions, parameters, or TODAY() or NOW(), will not be materialized in an extract as the value necessarily changes according to the current user, parameter selection, and system time. Tableau's optimizer may also determine whether to materialize certain calculations that are more efficiently performed in memory rather than having to read the stored value.

When you use an extract to materialize row-level calculations, only the calculations that were created at the time of the extract are materialized. If you edit calculated fields or create new ones after creating the extract, you will need to optimize the extract (use the drop-down menu on the data source or select it from the Data menu and then select Extract | Optimize or Extract | Compute Calculations Now).

As you continue to work with calculations, pay special attention to situations where you notice performance issues, and consider whether you can optimize your calculations for better results.

主站蜘蛛池模板: 会东县| 屏山县| 衢州市| 平阴县| 谷城县| 西平县| 孟津县| 阳高县| 犍为县| 临湘市| 临汾市| 乌恰县| 闸北区| 墨竹工卡县| 芷江| 年辖:市辖区| 资兴市| 承德县| 会理县| 台中县| 电白县| 饶阳县| 蒙阴县| 平武县| 宜良县| 庄河市| 红安县| 民勤县| 屏东县| 岳普湖县| 鸡东县| 广东省| 霞浦县| 旌德县| 陆河县| 镇平县| 深州市| 汉阴县| 铜鼓县| 朝阳县| 金乡县|