0

I use pg-promise to query a postgis database containing rasters. Queries are strings (with no parameters) generated before being processed by pg-promise.

The duration time of one query is typically 140ms (given by result function), while only 15ms in psql.

Example:

SELECT ST_Value(t_2m_1, ST_SetSrid(ST_MakePoint(5,50),4326)) AS t_2m_1 FROM iconeu_001 WHERE ST_Intersects(t_2m_1,ST_SetSrid(ST_MakePoint(5,50),4326));

Results: [ { t_2m_1: 4.61391601562502 } ] Duration: 147ms

While timing in psql:

      t_2m_1
------------------
 4.61391601562502
(1 row)

Time: 15.828 ms

It means that 90% of time is spent by pre and post processing the query as explained here.

Also, is there any way of dramatically speed up this steps (by skipping some unneeded steps for instance) ??

Thanks in advance.

PS: congratulations to vitaly-t for this excellent module !

Guillaume
  • 53
  • 7
  • You can execute multiple queries as one, via method [multi](http://vitaly-t.github.io/pg-promise/Database.html#multi). And you can automatically join them, using [helpers.concat](http://vitaly-t.github.io/pg-promise/helpers.html#.concat). – vitaly-t Oct 26 '18 at 13:30
  • Thanks for the tip! Unfortunately some of queries have to be executed one by one. For the ones that can be joined, I use task+batch method. Is it faster to use multi ? – Guillaume Oct 26 '18 at 15:29
  • `Is it faster to use multi?` - dramatically. That's one query request versus multiple. However, in 99% the performance issue you reported isn't real when it comes to real-world applications. Your measuring is likely skewed by a few x-factors. – vitaly-t Oct 26 '18 at 15:31

0 Answers0