Project

General

Profile

« Previous | Next » 

Revision 3285

sql_io.py: put_table(): mk_main_select(): Turned off unnecessary ORDER BY to avoid sorting the entire table every time it's used. (PostgreSQL has no concept of reordering a table and re-using that ordering, so it just re-sorts the table each time. Index scans on the pkey do not appear to be used in practice, according to EXPLAIN results from live imports.) Document that we instead assume that identical SELECT queries retrieve rows in the same order.

View differences:

lib/sql_io.py
316 316
    def mk_main_select(joins, cols):
317 317
        conds_ = [(sql_gen.with_table(k, insert_in_table), v) for k, v in conds]
318 318
        return sql.mk_select(db, joins, cols, conds_, limit=limit_ref[0],
319
            start=0)
319
            order_by=None, start=0)
320 320
    
321 321
    exc_strs = set()
322 322
    def log_exc(e):
......
453 453
        sql.add_row_num(db, insert_out_pkeys) # for joining with input pkeys
454 454
        
455 455
        log_debug('Getting input table pkeys of inserted rows')
456
        # Note that mk_main_select() does not use ORDER BY. Instead, assume that
457
        # since the SELECT query is identical to the one used in INSERT SELECT,
458
        # its rows will be retrieved in the same order.
456 459
        sql.run_query_into(db, mk_main_select(input_joins, [in_pkey]),
457 460
            into=insert_in_pkeys)
458 461
        sql.add_row_num(db, insert_in_pkeys) # for joining with output pkeys

Also available in: Unified diff