Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,
Dataset 1 : ( about Salesdetails)
Id , P1 , P2 , P3 , ...... P50
1 , 1223 , AABBB , 12Ac , ..........
Dataset 2 : (about formulas to find campaing)
ID , Formula
1 , if ((p1="123") and (Left(p2,2)="AA") ) or (Mid(P4,1,3)="A4")
2 , ....

We are combining Px( e.g. P1) values with Dataset1 P values and gets true or false. If true adds to list and at the end returns list of campaign Ids which calculation is True.

If Dataset1 has 7 rows and Datset2 has 200 rows ,loops every lines and calculate expression and it takes ~3500 ms ( for and parallel for )
And also in formulas we are using Left , Mid , Right , e.g.
Dou you have an idea to do this without loops or faster way ? (Parallel loops not fast as nornal for each loops)

Sample :
VB
Try
           Dim _list As New List(Of Class_Result)

           For Each r_formul As Data.DataRow In _Formuledata.Rows 'dataset2 has 210 records
               For Each r_order As Data.DataRow In _OrderData.Rows ' dataset1 has 7 records
                  ' gets P values from r_order and replace it in r_formul and calculates with MSscript
                   GetResult(r_formul, r_order, _list)
               Next
           Next
           Return _list
       Catch ex As Exception
           Return Nothing
       End Try
Posted
Updated 26-Jun-12 22:28pm
v3
Comments
OriginalGriff 27-Jun-12 3:00am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

A database redesign would be the only way I can think you could avoid this.

You could re-define your formulae to be in SQL and then execute them - so the record set you get back includes the boolean you are currently calculating in the loop.


Any alternative depends upon the flexibility allowed in your formulae.

for example, if there is a definitive list of absolute functions available, it would be possible to pre-calculate the values when adding data to the database.

Also, if you have to use Mid, Left etc. it seems your stored data is not atomic - i.e. if p1 beginning with 'AA' means something, then you really should have a column (on that table or elsewhere) describing what it means, so your query can access the data atomically
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900