Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any way to speed it up?
Message
 
 
À
09/01/2006 15:14:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01084765
Message ID:
01084954
Vues:
12
Ok, this process takes 5 minutes for 3000 accounts. I guess for 15K accounts it would take ~30 min., which is acceptable. Still if you see ways to optimize it, please let me know: (BTW, I re-indexed all my tables).
local loErr, lcBatch_Process_fk, lcUsGrLink_fk, ;
	lcNewStatusCode, lcDept, lnNumber_of_Days, ;
	ltTimeToReschedule, lcTrans_pk, lcTrans_Employees_Queues_pk, lcUser, ;
	lcAction, lcSubAction, lcDetail, lcOldCode, lcUsGrLink, llOldRecords

=aused(this.arrOriginallyUsed)

with this
	try
		.CreateLogfile()
		.WriteToLogFile(chr(13) + chr(10) + replicate("*",75) + chr(13) + chr(10), .t.)
		.WriteToLogFile("Started to run " + this.cSearchType + " Name Search process")

		.OpenSearchTables() && Opens related tables with buffering

		lcBatch_Processes_Fk = Get_Batch_Processes_Fk_By_Process_Name('POLICY NUMBER CHECK ')
		lcNewStatusCode = "NSR" && Name Search Requested
		if vartype(m.goApp) = "O"
			lcDept = m.goApp.cDept
			.nNumber_of_Days = m.goApp.oSystemParametersRecord.iNum_Days_NS_check
			.nNum_days_ns_Dos = m.goApp.oSystemParametersRecord.iNum_days_ns_dos
			lcUser = m.goApp.cUserID
			lcUsGrLink = m.goApp.cUsGrLink
		else
			lcDept = "O"
			.nNumber_of_Days = 5
			.nNum_days_ns_Dos = 716
			lcUser = GetUserID()
			lcUsGrLink = Get_System_USGRLink()
		endif

		=Get_description_from_Viscodes("STATUS","", m.lcDept, ;
			"cTempInfo",.f., 1, 'cCode_Value = "' + m.lcNewStatusCode + '"')
		lcNewStatusCode = cTempInfo.cVisCodes_pk

		use in select('cTempInfo')

		.SetDateToReschedule(.nNumber_of_Days)

		ltTimeToReschedule = dtot(.dRescheduleDate) + 9 * 3600 && 9am

		select curProcess
		scan
			if not empty(.cError) or .lStopProcess
				exit
			endif

			if .CheckRules()

				lcTrans_pk = curProcess.cTrans_pk
				lcTrans_Employees_Queues_pk = curProcess.cTrans_Employees_Queues_pk

				insert into Scheduled_Processes ;
					(cPROCESS_NAME_FK, cTrans_fk, cUsGrLink_fk, iBatch_Number, ;
					cClient_Code, cDepartment_Code, cProduct_Line_Code, ;
					tDate_Process_Scheduled, iStatus_Flag) ;
					values ;
					(m.lcBatch_Processes_Fk, m.lcTrans_pk, m.lcUsGrLink, 0, ;
					curProcess.cClient_Code, ;
					curProcess.cDepartment_Code, curProcess.cProduct_Line_Code, ;
					datetime(), 1)

				if seek(m.lcTrans_pk, "Trans")
					replace cStatus_Codes_fk with m.lcNewStatusCode, ;
						tStatus_Date with datetime(), ;
						cLast_Updated_User with m.lcUser, ;
						tLast_Updated_Date with datetime() ;
						in trans
				endif

				select Trans_Status_Codes
				if seek(m.lcTrans_pk)
					llOldRecords = .t.
					scan while cTrans_fk = m.lcTrans_pk
						replace cLast_Updated_User with m.lcUser, ;
							tLast_Updated_Date with datetime(), ;
							iActive_flag with 0 ;
							in Trans_Status_Codes
					endscan
				else
					llOldRecords = .f.
				endif

				if not m.llOldRecords && There were no status records already
					lcAction = "AD"
					lcSubAction = ""
					lcDetail = "STATUS WAS ADDED ON " + ;
						transform(datetime()) + " BY " + m.lcUser
				else
					lcAction = "CH" && change
					lcSubAction = "FR"
					if seek(curProcess.cStatus_Codes_fk, "VisCodes")
						lcOldCode = VisCodes.cCode_Description
					else
						lcOldCode = "OLD CODE"
					endif
					lcDetail = "STATUS WAS CHANGED FROM " + m.lcOldCode + ;
						" ON " + transform(datetime()) + " BY " + m.lcUser
				endif

				insert into Trans_Status_Codes ;
					(cTrans_fk, cStatus_Codes_fk, cUsGrLink_fk, tAS_OF_DATE, iActive_flag) ;
					values ;
					(m.lcTrans_pk, curProcess.cStatus_Codes_fk, m.lcUsGrLink, datetime(), 1)

				insert into Trans_Events ;
					(cTrans_fk, cFUNCTION_CODE, cACTION_CODE, cSUBACTION_CODE, cDETAIL_INFO) ;
					values ;
					(m.lcTrans_pk, "ST", m.lcAction, m.lcSubAction, m.lcDetail)

				select Employee_Queue_Schedules
				if seek(m.lcTrans_Employees_Queues_pk)
					scan while cTrans_Employees_Queues_fk = m.lcTrans_Employees_Queues_pk
						replace iActive_flag with 0, ;
							cLast_Updated_User with m.lcUser, ;
							tLast_Updated_Date with datetime() ;
							in Employee_Queue_Schedules
					endscan
				endif

				insert into Employee_Queue_Schedules (cTrans_Employees_Queues_fk, ;
					cDIARY_CODE_FK, ;
					tScheduled_Time, iActive_flag, ;
					iACTIVE_AT_DAY_START_FLAG, iSUPERVISOR_ASSIGNED_FLAG) ;
					values ;
					(m.lcTrans_Employees_Queues_pk, null, m.ltTimeToReschedule, 1, 1, 0)
			endif
		endscan

		if empty(.cError) and not .lStopProcess
			.CommitChanges()
		endif

		.WriteToLogFile("Finished to run " + this.cSearchType + " Name Search process" + chr(13) + chr(10))

	catch to loErr
		.CustomError(m.loErr)

	finally
		release loErr
		.CleanUp()
	endtry

endwith

return
>Hi Naomi,
>the numbers you reported are probably too high for that to be the only fix -
>gut feeling across the atlantic <bg>. You have re-checked indices and triggers ?
>
>HTH
>
>thomas
>
>>
>>Nice talking to you as always. I'll switch to seek and replace while and hopefully the performance improves. I'm using the tables in shared mode and with buffering 5. The CommitChanges method is going to do begin transaction and tableupdates on all these tables.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform