UPDATE STATISTICS (U-SQL)

Summary

U-SQL provides the UPDATE STATISTICS statement to update a previously created statistic on a table.

Syntax

Update_Statistics_Statement :=                                                                           
     'UPDATE' 'STATISTICS' ['IF' 'EXISTS']
     Statistic_Name 'ON' Table_Name
     'WITH' 'INCREMENTAL' '=' ('ON' | 'OFF').
Statistic_Name := Quoted_or_Unquoted_Identifier.
Table_Name := Identifier.

Remarks

  • Statistic_Name ON Table_Name
    Specifies the name (either a quoted or unquoted identifier) of the statistic of the given table to be updated. If the statistic does not exist or the user does not have permissions, then an error is raised, unless IF EXISTS is specified. In that case, if the user has at least enumeration permission on the table, the operation will silently complete without action. If the user has no enumeration permission, an error is raised.

  • WITH INCREMENTAL = 'ON' | 'OFF'
    When the INCREMENTAL option is set to ON, the statistics are updated with the newly inserted data and newly added partitions since the last time the statistic got calculated. If it is set to OFF, the statistics tree is dropped and the full statistic is recomputed.

Examples

  • The example can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
  • The script can be executed locally. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.

The following example does a full update of the statistics, ordersStats, within the table Orders in TestReferenceDB.

USE TestReferenceDB;

UPDATE STATISTICS IF EXISTS ordersStats 
ON dbo.Orders
WITH INCREMENTAL = OFF;

See Also