Re: script or spl for update statistics
Posted in 1997
> >Hi, > >in Informix Guide To SQL Syntax there is recommendation for updating >statistics: >1) run update statistics with distributions only >2) run update statistics high for columns with indexes >3) run update statistics low for multicolumn indexes > >I would like to do recommended update statistics regularly (via cron). >Does anybody has SPL or script (or anything convenient) that is able to >do such a update. > At work we use a failry simple script that updates statistics for all tables every day at 2:00 AM. The entry in crontab is: 0 2 * * * /u/cta/bin/statistics The script in /u/cta/bin is: if [ a$INFORMIXDIR = a ] then . /u/corona/etc/profile # This is the script for seting INFORMIXDIR # PATH, DBDATE, etc fi exec_sql 'update statistics' The exec_sql script is also in /u/cta/bin and is: fglgo /u/cta/lib/exec_sql.4gi "$*" Note that this script executes almost ANY sql command from the shell! The 4gl for the program is: DATABASE cta MAIN DEFINE w_texto CHAR(256), w_args, i SMALLINT; LET w_args = num_args() IF w_args = 0 THEN DISPLAY "Uso: sql <commando>" DISPLAY " " ELSE LET w_texto = "" FOR i = 1 to w_args LET w_texto = w_texto CLIPPED, " ", arg_val(i) CLIPPED END FOR WHENEVER ERROR CONTINUE PREPARE l_com FROM w_texto IF status = 0 THEN EXECUTE l_com IF status <> 0 THEN DISPLAY "RTS ERROR : ", sqlca.sqlcode, " ", sqlca.sqlerrm END IF ELSE DISPLAY "ERROR : ", sqlca.sqlcode, " ", sqlca.sqlerrm DISPLAY "EN COMANDO", w_texto CLIPPED END IF END IF END MAIN Excuse the spanish in the code but I thing still is failry clear. Hope it helps.