Project

General

Profile

« Previous | Next » 

Revision 3269

sql.py with_explain_comment(), DbConn: Fixed bug where with_explain_comment() was being run in per-row imports (row-based import and csv2db with INSERT), causing the overhead of an EXPLAIN query for every single INSERT and filling up the cache with EXPLAIN query results, by adding autoexplain mode, only running with_explain_comment() in autoexplain mode, and only enabling autoexplain mode for column-based import

View differences:

lib/sql.py
167 167
        self.log_debug = log_debug
168 168
        self.debug = log_debug != log_debug_none
169 169
        self.debug_temp = debug_temp
170
        self.profile_row_ct = None
171 170
        self.src = src
172 171
        self.autoanalyze = False
172
        self.autoexplain = False
173
        self.profile_row_ct = None
173 174
        
174 175
        self._savepoint = 0
175 176
        self._reset()
......
555 556
def has_comment(query): return query.endswith('*/')
556 557

  
557 558
def with_explain_comment(db, query, **kw_args):
558
    if db.debug and not has_comment(query) and is_explainable(query):
559
    if db.autoexplain and not has_comment(query) and is_explainable(query):
559 560
        query += '\n'+sql_gen.esc_comment(' EXPLAIN:\n'
560 561
            +explain(db, query, **kw_args))
561 562
    return query
lib/db_xml.py
157 157
    # Subset and/or partition in_table if needed
158 158
    if top_call:
159 159
        db.autoanalyze = True # but don't do this in row-based import
160
        db.autoexplain = True # but don't do this in row-based import
160 161
        
161 162
        full_in_table = in_table
162 163
        

Also available in: Unified diff