Skip to content

Instantly share code, notes, and snippets.

@tym-xqo
Created April 22, 2015 19:01
Show Gist options
  • Save tym-xqo/cef11958aca90157927e to your computer and use it in GitHub Desktop.
Save tym-xqo/cef11958aca90157927e to your computer and use it in GitHub Desktop.
local machine vs. qa database execution timing

Same query EXPLAIN plan run from my local machine vs. from shell on qa.iadops.com

My laptop:

oao_trial=> explain analyze insert into test values (7418880);
                                         QUERY PLAN
--------------------------------------------------------------------------------------------
 Insert on test  (cost=0.00..0.01 rows=1 width=0) (actual time=0.280..0.280 rows=0 loops=1)
   ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.004 rows=1 loops=1)
 Planning time: 0.183 ms
 Execution time: 0.502 ms
(4 rows)

Time: 25.366 ms

On QA machine:

oao_trial=# explain analyze insert into test values (7418880);
                                         QUERY PLAN
--------------------------------------------------------------------------------------------
 Insert on test  (cost=0.00..0.01 rows=1 width=0) (actual time=0.055..0.055 rows=0 loops=1)
   ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.004 rows=1 loops=1)
 Planning time: 0.026 ms
 Execution time: 0.086 ms
(4 rows)

Time: 1.433 ms

Note that "Execution time" is the query planner's record of actual time on server. The "Time:" line at the end of each is elapsed time as recorded client-side. The 24ms difference corresponds very closely to the avg latency between my laptop and qa as reported by mtr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment