1

Is there a way to force netezza to generate full statistics on a table using SQL. I know it is possible to do via command line but that require nzsql client to be installed on the machine that initiates this command. According to the details mentioned here - https://www.ibm.com/support/pages/understanding-generate-statistics-statement it may be possible to force NZ to assume that the target table (on which we want to run full stats) is small / medium (set sample_stats_min_Rows = 1000000;) so that it generates full statistics with the "GENERATE STATISTICS ON " command. However, it seems that like the sample_stats_min_rows is not a valid option anymore as it gives an error ERROR [HY000] ERROR: 'SAMPLE_STATS_MIN_ROWS' is not a valid option name. We have seen a massive difference in performance with full stats against express statistics and hence the request. The version we have is Release 7.2.1.10-P1

Kausty
  • 899
  • 2
  • 10
  • 22

1 Answers1

3

nz_genstats has the option to generate full statistics. if you dig into the script, this is what it's setting to accomplish this

full stats

SET ENABLE_JIT_DISPERSION=FALSE;
SET ENABLE_JIT_STATS=ON;
GENERATE STATISTICS ON $TABLENAME;

for express stats

SET ENABLE_JIT_DISPERSION=TRUE;
SET ENABLE_JIT_STATS=ON;
SET JIT_DISP_MIN_ROWS=999999999999999;
GENERATE EXPRESS STATISTICS ON $TABLENAME;

for basic stats

SET ENABLE_JIT_DISPERSION=TRUE;
SET ENABLE_JIT_STATS=ON;
SET JIT_DISP_MIN_ROWS=1;
SET ENABLE_GENSTATS_DISPERSION=FALSE;
GENERATE STATISTICS ON $SQL_TABLENAME;
Mike DeRoy
  • 133
  • 7
  • 1
    Thank you so much Mike! This helped. Unfortunately, we did not have option to explore the script in itself but as you laid out the commands for it, it seems to work to get us the full statistics. – Kausty Apr 28 '21 at 20:37
  • 2
    Call your friendly local DBA and ask him to create a ‘backup’ (copy) of all the nz_* scripts on a different server. They contain a TON of knowledge :) #MarkFraaseForPresident – Lars G Olsen Apr 29 '21 at 17:56
  • Agreed #MarkFraaseForPresident :) – Mike DeRoy Apr 30 '21 at 12:50