sql - The initialization time of a query -
i'm new in query analyzing , understand concept mean. instance ran explain analyze query , got following row:
->  sort  (cost=816428.39..827478.32 rows=4419971 width=21)         (actual time=10780.477..12520.838 rows=4415703 loops=1) as far google around it, in actual time=10780.477..12520.838  first number means time spent initialization, second 1 whole time spent part of query.
what initialization mean , why takes major part of execution
short: short answer question possible initiation time time taken find query execution plan + waiting locks.
elaboration: given in pg documentation, 2 numbers mentioned within 'actual times' are:
- start time: time in millisecond when node started evaluate. (since haven't given entire - explain analyseoutput, can't tell sure whether first node in execution plan). if first node evaluated, time time taken generate plan / time spent while waiting locks (if required) etc. however, if 'not' first node in execution plan, first millisecond when first data-item reached node, previous node in execution plan.
- stop time: time in millisecond when node execution stopped. notably, second number 'not' time taken node, stop-time. 
to elaborate take @ explain analyse output below:
# explain analyse update t set = 20 = 10;                                             query plan ---------------------------------------------------------------------------------------------------  update on t  (cost=0.00..40.00 rows=12 width=6) (actual time=5719.955..5719.955 rows=0 loops=1)    ->  seq scan on t  (cost=0.00..40.00 rows=12 width=6) (actual time=0.015..0.018 rows=1 loops=1)          filter: (a = 10)  total runtime: 5719.985 ms (4 rows) although sequence scan went through fast, actualy update took time because in transaction locked row 5+ seconds... , update row took more 5000 milliseoncds (5 seconds) begin executing.
Comments
Post a Comment