Postgresql – DataGrip shows a time substantially slower than EXPLAIN ANALYZE

datagripperformancepostgresqlpostgresql-performance

I searched alot for the answer to my question.

I have a table with 134 rows and 4 rows. My EXPLAIN ANALYZE says the execution time was: 0.038ms. But the actual execution time (using DataGrip) was: 123ms

A complex query with multiple joins shows these stats:
EXPLAIN ANALYZE execution time: 38.605ms
DataGrip execution time: 177ms

My VPS has 2GB ram and 2 vCores.

Is it more likely a problem with my server or my config, or is this behavior normal?

Here is the EXPLAIN ANALAYZE of the simple select:

Seq Scan on champions  (cost=0.00..4.34 rows=134 width=37) (actual time=0.007..0.024 rows=134 loops=1)
Planning time: 0.053 ms
Execution time: 0.044 ms

Here is the log of DataGrip:

[2017-02-10 21:38:30] 134 rows retrieved starting from 1 in 135ms (execution: 127ms, fetching: 8ms)

I am really confused!

EDIT:

These are my only changes to my config:

max_connections = 200
shared_buffers = 512MB
effective_cache_size = 1536MB
work_mem = 32MB
maintenance_work_mem = 128MB
min_wal_size = 1GB
max_wal_size = 2GB
checkpoint_completion_target = 0.7
wal_buffers = 16MB
default_statistics_target = 100
listen_addresses = '*'

Best Answer

  • EXPLAIN ANALYZE is showing you the planning and execution time.
  • DataGrip is showing you the completion time. This may include,

    1. Network transit
    2. Drawing in the GUI, etc.

Just think, if you have a one-row table with one bytea column that contains 2GB, transferring it across the network or even using TCP/IP will be a substantial transit compared to the planning and execution of the query.

[2017-02-10 21:38:30] 134 rows retrieved starting from 1 in 135ms (execution: 127ms, fetching: 8ms)

That's 134 rows you didn't have to retrieve using EXPLAIN ANALYZE.