python - Difference between Sqlalchemy execution time and execution time from EXPLAIN query? -


i using postgresql flask , sqlalchemy. found if in python,

t1 = datetime.datetime.now() session.query(table_class).all() t2 = datetime.datetime.now() print (t2 - t1) 

i getting execution time of sqlalchemy query. if go postgresql , write same sql statement explain analyse can execution time of sql query. like,

explain analyse select * table; 

i found difference between these execution times much. sqlalchemy execution time 10 times execution time explain query. small queries 2 times (75ms , 2 ms) , long queries many joins times (1.5sec , 200ms). don't know why happening. why these times have big difference?

the difference cause communication overhead. when run explain analyse measuring exact time of query in postgres database. when measure time in python code measuring time of query execution plus: time of connecting database, sending data, receiving/parsing result, etc. depending on amount of data transferred , physical location of database can expect significant overhead in communication compared actual execution time of query.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -