HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

DataGrip shows a time substantially slower than EXPLAIN ANALYZE

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
analyzethanslowertimeshowsexplaindatagripsubstantially

Problem

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 = '*'

Solution


  • EXPLAIN ANALYZE is showing you the planning and execution time.



-
DataGrip is showing you the completion time. This may include,

  • Network transit



  • 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.

Context

StackExchange Database Administrators Q#163935, answer score: 3

Revisions (0)

No revisions yet.