Project

General

Profile

« Previous | Next » 

Revision 10845

bugfix: lib/sql_io.py: put_table(): Getting output table pkeys of existing/inserted rows: need to include the index cond in the join condition here, too (using var join_custom_cond), so that an index scan can be used instead of a much slower full-table sort

View differences:

sql_io.py
504 504
        insert_in_table = in_table
505 505
        insert_in_tables = [insert_in_table]
506 506
    join_cols = sql_gen.ColDict(db, out_table)
507
    join_custom_cond = None
507 508
    
508 509
    exc_strs = set()
509 510
    def log_exc(e):
......
729 730
            # supported
730 731
            assert not join_cols
731 732
            
733
            join_custom_cond = e.cond
732 734
            if e.cond != None: ensure_cond(e.cond, e, passed=True)
733 735
            
734 736
            join_cols.update(util.dict_subset_right_join(mapping, e.cols))
......
803 805
    
804 806
    if is_function: pass # pkeys table already created
805 807
    elif has_joins:
806
        select_joins = input_joins+[sql_gen.Join(out_table, join_cols)]
808
        select_joins = input_joins+[sql_gen.Join(out_table, join_cols,
809
            custom_cond=join_custom_cond)]
807 810
        log_debug('Getting output table pkeys of existing/inserted rows')
808 811
        insert_into_pkeys(sql.mk_select(db, select_joins, [in_pkey_col,
809 812
            sql_gen.NamedCol(into_out_pkey, out_pkey_col)], order_by=None))

Also available in: Unified diff