Public Sub RefreshRowNumbers(g As DataGridView)
For Each r As DataGridViewRow In g.Rows
r.Cells(1).Value = r.Index + 1
Next
End Sub
Private Sub DataGridView1_RowsRemoved(sender As Object, _
e As DataGridViewRowsRemovedEventArgs) Handles DataGridView1.RowsRemoved
RefreshRowNumbers(DirectCast(sender, DataGridView))
End Sub
Private Sub DataGridView1_RowsAdded(sender As Object, _
e As DataGridViewRowsAddedEventArgs) Handles DataGridView1.RowsAdded
RefreshRowNumbers(DirectCast(sender, DataGridView))
End Sub
我有上面的视图,它是为执行必要的计算而创建的。我面临的问题需要5分钟才能运行。
这是我的sql trace输出:
create view "informix".v_prod_cost (ship_no,dc_id,whse_id,cust_id,prod_id,
unit_cost_excl,unit_cost_incl,vat_perc,is_catch_wght,tot_cost_excl,tot_cost_incl) as
SELECT x3.ship_no, x1.dc_id, x1.whse_id, x4.cust_id, x1.prod_id,
x5.case_cost, round(((x5.case_cost * (x7.cvat_desc ::smallint
+ 100. ) ) / 100.0000000000000000 ) , 2 ), x7.cvat_desc,
CASE WHEN ((x4.catch_wgt_ctl = 'Y' ) AND (x5.catch_wgt_cntl
= 'Y' ) ) THEN 'Y' WHEN ((x4.catch_wgt_ctl = 'N' ) AND (x5.catch_wgt_cntl
= 'Y' ) ) THEN 'N' ELSE 'N' END,
CASE WHEN ((x4.catch_wgt_ctl
= 'Y' ) AND (x5.catch_wgt_cntl = 'Y' ) ) THEN round(sum((select
(sum(x9.catch_wgt ) * x5.case_cost ) from "informix".icwma
x8 ,"informix".icwmad x9 where (((((((((((x8.cwma_id = x9.cwma_id
) AND (x8.dc_id = x1.dc_id ) ) AND (x8.whse_id = x1.whse_id
) ) AND (x8.curr_pal_no = x1.curr_pal_no ) ) AND (x8.ord_id
= x1.ord_id ) ) AND (x8.prod_id = x1.prod_id ) ) AND (x8.invc_id
= x1.invc_id ) ) AND (x8.sgmt_id = x1.sgmt_id ) ) AND (x8.unit_ship_cse
= x1.unit_ship_cse ) ) AND (x8.assg_id = x1.assg_id ) ) AND
(x8.ckpt_id = x1.ckpt_id ) ) ) ) , 2 ) WHEN ((x4.catch_wgt_ctl
= 'N' ) AND (x5.catch_wgt_cntl = 'Y' ) ) THEN round(sum((((x1.prod_qty
/ x1.unit_ship_cse ) * x1.prod_wgt ) * x5.case_cost ) ) ,
2 ) ELSE round(sum((x1.prod_qty * x5.case_cost ) ) , 2
) END,
CASE WHEN ((x4.catch_wgt_ctl = 'Y' ) AND (x5.catch_wgt_cntl
= 'Y' ) ) THEN round(sum((select (((sum(x11.catch_wgt ) *
x5.case_cost ) * (x7.cvat_desc ::smallint + 100. ) ) / 100.0000000000000000
) from "informix".icwma x10 ,"informix".icwmad x11 where (((((((((((x10.cwma_id
= x11.cwma_id ) AND (x10.dc_id = x1.dc_id ) ) AND (x10.whse_id
= x1.whse_id ) ) AND (x10.curr_pal_no = x1.curr_pal_no )
) AND (x10.ord_id = x1.ord_id ) ) AND (x10.prod_id = x1.prod_id
) ) AND (x10.invc_id = x1.invc_id ) ) AND (x10.sgmt_id =
x1.sgmt_id ) ) AND (x10.unit_ship_cse = x1.unit_ship_cse
) ) AND (x10.assg_id = x1.assg_id ) ) AND (x10.ckpt_id =
x1.ckpt_id ) ) ) ) , 2 ) WHEN ((x4.catch_wgt_ctl = 'N' )
AND (x5.catch_wgt_cntl = 'Y' ) ) THEN round(sum(((((x1.prod_qty
/ x1.unit_ship_cse ) * x1.prod_wgt ) * x5.case_cost ) * (x7.cvat_desc
::smallint + 100. ) ) ) , 2 ) ELSE round(sum((((x1.prod_qty
* x5.case_cost ) * (x7.cvat_desc ::smallint + 100. ) ) /
100.0000000000000000 ) ) , 2 ) END
FROM "informix".ishs x0,
"informix".ishd x1, "informix".irtst x2, "informix".crtst x3,
"informix".icust x4, "informix".iprod x5, "informix".cprod x6,
"informix".cvat x7
WHERE ((((((((((((x0.shs_id = x1.shs_id
) AND (x0.dc_id = x1.dc_id ) ) AND (x0.whse_id = x1.dc_id
) ) AND (x0.rtst_id = x2.rtst_id ) ) AND (x0.dc_id = x2.dc_id
) ) AND (x1.whse_id = x2.dc_id ) ) AND (x2.rtst_id = x3.rtst_id
) ) AND (x1.cust_id = x4.cust_id ) ) AND (x1.dc_id = x5.dc_id
) ) AND (x1.prod_id = x5.prod_id ) ) AND (x5.prod_id = x6.prod_id
) ) AND (x6.vat_ind = x7.vat_ind ) )
GROUP BY x3.ship_no, x1.dc_id, x1.whse_id, x4.cust_id, x1.prod_id,
x5.case_cost, 7, x7.cvat_desc, 9, x4.catch_wgt_ctl, x5.catch_wgt_cntl
;
我可以做些什么来降低嵌套循环和动态散列连接的成本?