同一查询的多个并发调用在一次调用中返回的时间乘以调用次数

时间:2018-10-25 11:30:43

标签: postgresql

在并发方式下使用连接池在Postgres 10上运行以下查询时,结果返回n *运行一次调用所需的时间。

在Racket中使用线程和带有promise的Node进行了测试。两者都以毫秒为单位返回〜相同的时间。

1次调用: 8322

10次调用:

82432、82260、82025、82260、82432、82103、82025、82556、82040、82119

以下是查询:

WITH contact_searches as (select
md.geo_point as md_point, md.sf_id as md_name, md.sf_id as md_sf_id, 
md.freehold_tenure as md_fh_ten,
md.freehold_search_price md_fh_sp, md.leasehold_tenure as md_lh_ten, 
md.leasehold_search_price as md_lh_sp,
md.special_tenure_search_price as md_st_sp, md.geo_point as point,
ss.freehold_tenure as ss_fh_ten, ss.leasehold_tenure as ss_lh_ten, 
ss.price_from as ss_pf, ss.price_to as ss_pt, md.marketing_trades as md_trades, 
ss.trades as ss_trades,
ss.sf_id as ss_sf_id, ss.person_id as person_id, ss.areas as areas
from saved_searches ss
inner join marketing_details md on md.marketing_trades && ss.trades
where md.sf_id = ANY ($1)
and
((md.freehold_tenure is not null  and ss.freehold_tenure ='true'
and (md.freehold_search_price is null or md.freehold_search_price >= ss.price_from)
and (md.freehold_search_price is null or md.freehold_search_price <= ss.price_to))
or
(md.leasehold_tenure is not null  and ss.leasehold_tenure ='true'
and (md.leasehold_search_price is null or md.leasehold_search_price >= ss.price_from)
and (md.leasehold_search_price is null or md.leasehold_search_price <= ss.price_to))
or
(md.special_tenure_search_price is not null
and (md.special_tenure_search_price >= ss.price_from)
and (md.special_tenure_search_price <= ss.price_to))
)
), contact_ids as (select distinct person_id as sf_id
from contact_searches inner join areas a on st_contains(a.polygon, contact_searches.point) 
where a.name = ANY (contact_searches.areas))
select c.sf_id, hasoptedoutofemail, preferred_contact_method, cco_email_opt_out, cf_email_opt_out,  valid_email(c)
from contacts c inner join contact_ids on c.sf_id = contact_ids.sf_id where c.applicant_status = 'Live'

对于复杂的查询是否不在parralell中运行,或者是否有我可以进行的配置更改或其他有帮助的事情,是否有人有任何见识?

0 个答案:

没有答案