VALIDATE_STATISTICS
Validates statistics in the XML file generated by EXPORT_STATISTICS
.
Syntax
VALIDATE_STATISTICS ( 'XML‑file' )
Parameters
XML‑file |
the path and name of the XML file that contains the statistics to validate. |
Privileges
Superuser
Reporting Valid Statistics
The following example shows the results when the statistics are valid:
=> SELECT EXPORT_STATISTICS('cust_dim_stats.xml','customer_dimension'); EXPORT_STATISTICS ----------------------------------- Statistics exported successfully (1 row)
=> SELECT VALIDATE_STATISTICS('cust_dim_stats.xml'); VALIDATE_STATISTICS --------------------- (1 row)
Identifying Invalid Statistics
If VALIDATE_STATISTICS
is unable to read a document's XML, it throws this error:
=> SELECT VALIDATE_STATISTICS('/home/dbadmin/stats.xml'); VALIDATE_STATISTICS ---------------------------------------------------------------------------- Error validating statistics file: At line 1:1. Invalid document structure (1 row)
If some table statistics are invalid, VALIDATE_STATISTICS
returns a report that identifies them. In the following example, the function reports that attributes distinct
, buckets
, rows
, count
, and distinctCount
cannot be negative numbers.
=> SELECT VALIDATE_STATISTICS('/stats.xml'); WARNING 0: Invalid value '-1' for attribute 'distinct' under column 'public.t.x'. Please use a positive value. WARNING 0: Invalid value '-1' for attribute 'buckets' under column 'public.t.x'. Please use a positive value. WARNING 0: Invalid value '-1' for attribute 'rows' under column 'public.t.x'. Please use a positive value. WARNING 0: Invalid value '-1' for attribute 'count' under bound '1', column 'public.t.x'. Please use a positive value. WARNING 0: Invalid value '-1' for attribute 'distinctCount' under bound '1', column 'public.t.x'. Please use a positive value. VALIDATE_STATISTICS --------------------- (1 row)
In this case, run ANALYZE_STATISTICS
on the table again to create valid statistics.