InseeFr/Trevas

Cast operator: slowed down a lot execution

Closed this issue · 2 comments

To investigate

VTL script sample:

test := input_table[calc i_ind := if IND in {"1", "2", "3", "4", "5", "6", "7", "8", "9"} then 1 else 0]
                   [calc i_cometu := if (length(COMETU) = 5 or isnull(COMETU)) then 1 else 0]
                   [calc i_cometa := if (length(COMETA) = 5 or isnull(COMETA)) then 1 else 0]
                   [calc i_comref := if (length(COMREF) = 5 or isnull(COMREF)) then 1 else 0]
                   [calc i_cp_etu := if (length(CP_ETU) = 5 or isnull(CP_ETU)) then 1 else 0]
                   [calc i_cp_par := if (length(CP_PAR) = 5 or isnull(CP_PAR)) then 1 else 0]
                   [calc i_etabli := if (length(ETABLI) = 8 or isnull(ETABLI)) then 1 else 0]
                   [calc i_ind_franc := if FR_ETR in {"0", "1"} then 1 else 0]
                   [calc i_idresil := if length(IDRESIL_SISE20) > 0 then 1 else 0]
                   [calc i_net := if NET in {"0", "1"} then 1 else 0]
                   [calc i_paripa := if length(PARIPA) = 3 then 1 else 0]
                   [calc i_situpre := if SITUPRE in {"A", "B", "C", "D", "E", "G", "H", "J", "K", "M", "P", "Q", "R", "S", "T", "U"} then 1 else 0]
                   [keep i_ind, i_cometu, i_cometa, i_comref, i_cp_etu, i_cp_par, i_etabli, i_ind_franc, i_idresil, i_net, i_paripa, i_situpre]
;

More efficient grouping calc clauses:

test := input_table [calc i_ind := if IND in {"1", "2", "3", "4", "5", "6", "7", "8", "9"} then 1 else 0,
                   i_cometu := if (length(COMETU) = 5 or isnull(COMETU)) then 1 else 0,
                   i_cometa := if (length(COMETA) = 5 or isnull(COMETA)) then 1 else 0,
                   i_comref := if (length(COMREF) = 5 or isnull(COMREF)) then 1 else 0,
                   i_cp_etu := if (length(CP_ETU) = 5 or isnull(CP_ETU)) then 1 else 0,
                   i_cp_par := if (length(CP_PAR) = 5 or isnull(CP_PAR)) then 1 else 0,
                   i_etabli := if (length(ETABLI) = 8 or isnull(ETABLI)) then 1 else 0,
                   i_ind_franc := if FR_ETR in {"0", "1"} then 1 else 0,
                   i_idresil := if length(IDRESIL_SISE20) > 0 then 1 else 0,
                   i_net := if NET in {"0", "1"} then 1 else 0,
                   i_paripa := if length(PARIPA) = 3 then 1 else 0,
                   i_situpre := if SITUPRE in {"A", "B", "C", "D", "E", "G", "H", "J", "K", "M", "P", "Q", "R", "S", "T", "U"} then 1 else 0]
                   [keep i_ind, i_cometu, i_cometa, i_comref, i_cp_etu, i_cp_par, i_etabli, i_ind_franc, i_idresil, i_net, i_paripa, i_situpre]
;