我使用下面的子查询来获取附加记录。我需要知道它是否为我的任务优化了查询(似乎在三个月内它的存在记录超过 10,000 条)。那么它是否支持该数据加载。?
我可以使用JOIN关键字代替下面的方法吗?请建议我解决这个问题。目前我正在使用 postgresql 作为我的后端。
select worker,worktype,paymenttype,sum(output)as totalkgs_ltrs,sum(overkgs)as overkgs_ltrs,sum(workedhrs) as workedhrs,sum(scrap) as scrap,sum(cashworkincome) as cashworkincome,sum(pss) as pss
from (select
comp.name as company,
est.name as estate,
div.name as division,
wkr.name as worker,
txn.date as updateddate,
txn.type as worktype,
txn.payment_type as paymenttype,
txn.names as workedhrs,
txn.norm as norm,
txn.output as output,
txn.over_kgs as overkgs,
txn.scrap as scrap,
txn.cash_work_income as cashworkincome,
txn.pss as pss
from
bpl_daily_transaction_master txn,
res_company comp,
bpl_division_n_registration div,
bpl_estate_n_registration est,
bpl_worker wkr
where
comp.id = txn.bpl_company_id and
div.id = txn.bpl_division_id and
est.id = txn.bpl_estate_id and
wkr.id = txn.worker_id
)as subq
group by worker,worktype,paymenttype
这里显示了我执行此查询时的结果
这是在底部标记的子查询的代码和结果
select
comp.name as company,
est.name as estate,
div.name as division,
wkr.name as worker,
txn.date as updateddate,
txn.type as worktype,
txn.payment_type as paymenttype,
txn.names as workedhrs,
txn.norm as norm,
txn.output as output,
txn.over_kgs as overkgs,
txn.scrap as scrap,
txn.cash_work_income as cashworkincome,
txn.pss as pss
from
bpl_daily_transaction_master txn,
res_company comp,
bpl_division_n_registration div,
bpl_estate_n_registration est,
bpl_worker wkr
where
comp.id = txn.bpl_company_id and
div.id = txn.bpl_division_id and
est.id = txn.bpl_estate_id and
wkr.id = txn.worker_id
这是主要查询结果的上方,它显示了所有记录