Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any way to speed this up
Message
From
25/01/2005 13:17:21
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00980402
Message ID:
00980455
Views:
33
This message has been marked as the solution to the initial question of the thread.
Nadya,

I've found out that requery() of a (complex ?) view that retrieves just one record takes time. If you multiply that with the number of records in the scan ...
It may save time to
    select ..... ;
       from ScanCursor, table1, ......
       [ or join ]
       [ or where clause ]
      into cursor (c_QuickSearch)
Could you do with just one (complex ?) select into (c_QuickSearch) ?
Should be fast if you have the proper indexes

Sometimes it saves time to break down a complex sql statement into a couple of simpler sql statements
&& first select from the table with the highest number of records, if you have a choice in your navigation route
select ... ;
   from ScanCursor, Table1 ;
   where
   into cursor subset1

&& if the subsets are hughe, it helps sometimes to index a subset and then carry on with the next select
select ... ;
   from subset1, table2 ;
   where ...
   into susbset2

...

select ... ;
   from subsetN, table x ;
   into cursor (c_QuickSearch) ;
   order by ....
You need to experiment a bit

Oh, and only select the fields you need
_________________________

>Hi everybody,
>
>I'm working on the search form. I first do requery of the view, then do some post-processing of this view to get all the needed data. The requery of the view takes less than a second. But the post-processing takes 20 seconds for a 115 records scan. I am looking for the ideas of optimizing the code bellow. I tried another variation of this code with appending records into the cursor and then replacing, but it took the same amount of time. May be you can see what can I improve?
>
>
>*---------------------- Location Section ------------------------
>*   Library: 	Aquicksearchbiz.vcx
>*   Class: 		Quicksearchobject
>*   Method: 	Createfinalresult()
>*----------------------- Usage Section --------------------------
>*)  Description:
>*)
>
>*   Scope:      Public
>*   Parameters:
>*$  Usage:
>*$
>*   Returns:
>*--------------------- Maintenance Section ----------------------
>*   Change Log:
>*       CREATED 	01/24/2005 - NN
>*		MODIFIED
>*----------------------------------------------------------------
>LOCAL lnReccount, loSelect, cStatus, cUserID, lnSeconds
>lnSeconds = SECONDS()
>SET TALK OFF
>SET NOTIFY OFF
>
>WITH THIS
>	loSelect = .SelectAlias()
>	SCAN
>		IF VARTYPE(m.plStop) = "L" AND m.plStop
>			.EmptySearchResult() && Search was cancelled
>			EXIT
>		ELSE
>
>			.cTrans_FK = cTrans_PK
>
>				.REQUERY(.T.,"v_Commissioned_Owner")
>			** Let's do by VFP commands to avoid overhead
>			
>*!*				vp_cTrans_FK = cTrans_Pk
>*!*				REQUERY("v_Commissioned_Owner")
>			
>			cUserID = v_Commissioned_Owner.cUserID
>
>* cStatus field is either status description or resolution description if the resolution code is not empty
>			IF EMPTY(cResolution_Codes_Fk) OR ISNULL(cResolution_Codes_Fk)
>				.cViscodes_pk = cStatus_Codes_FK
>*				vp_cViscodes_pk = cStatus_Codes_FK
>			ELSE
>				.cViscodes_pk = cResolution_Codes_Fk
>*				vp_cViscodes_pk = cResolution_Codes_Fk
>			ENDIF
>
>			.REQUERY(.T.,"v_VisCodes_Lookup")
>*            REQUERY("v_VisCodes_Lookup")
>			cStatus = v_VisCodes_Lookup.cCode_Description
>
>			SCATTER MEMVAR
>
>			SELECT c_QuickSearch
>
>			INSERT INTO c_QuickSearch FROM MEMVAR
>		ENDIF
>	ENDSCAN
>	GO TOP IN c_QuickSearch
>ENDWITH
>
>lnReccount = RECCOUNT("c_QuickSearch")
>=MESSAGEBOX("Populating cursor took " + TRANSFORM(SECONDS() - m.lnSeconds) + " seconds")
>RETURN m.lnReccount
>
>
>Thanks in advance.
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform