Revision 3047
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/sql.py | ||
---|---|---|
1088 | 1088 |
|
1089 | 1089 |
col.table.index_cols[col.name] = new_col |
1090 | 1090 |
|
1091 |
# Controls when ensure_not_null() will use index columns |
|
1092 |
not_null_index_cols_min_rows = 0 # rows; initially always use index columns |
|
1093 |
|
|
1091 | 1094 |
def ensure_not_null(db, col): |
1092 | 1095 |
'''For params, see sql_gen.ensure_not_null()''' |
1093 | 1096 |
expr = sql_gen.ensure_not_null(db, col) |
1094 | 1097 |
|
1095 |
# If nullable column in a temp table, add separate column instead |
|
1096 |
if sql_gen.is_temp_col(col) and isinstance(expr, sql_gen.EnsureNotNull): |
|
1098 |
# If a nullable column in a temp table, add separate index column instead. |
|
1099 |
# Note that for small datasources, this adds 6-25% to the total import time. |
|
1100 |
if (sql_gen.is_temp_col(col) and isinstance(expr, sql_gen.EnsureNotNull) |
|
1101 |
and table_row_count(db, col.table) >= not_null_index_cols_min_rows): |
|
1097 | 1102 |
add_index_col(db, col, '::NOT NULL', expr, nullable=False) |
1098 | 1103 |
expr = sql_gen.index_col(col) |
1099 | 1104 |
|
Also available in: Unified diff
sql.py: ensure_not_null(): Made the use of index columns configurable based on the # of rows in the table, because for small datasources, they seem to add 6-25% to the total import time