MySQL script optimization.