Normal Topic Speed up technique does not work anymore (Read 821 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Speed up technique does not work anymore
May 25th, 2007 at 8:09pm
Print Post Print Post  
Quote:
Yes, you can speed up the XLookup - without making it internal. Using an external XLookup, you can put an XLookup in the GLOBAL CODE section. It will run when the form is opened. It can even be a "bad" Xlookup, using an non-existent LE name in the key field. Just make sure it uses the same .db file as the "real" XLookup that will run later. Then, put the "real" XLookup in the event where it is really supposed to go.

The XLookup in GLOBAL CODE will run first, so the form will take a few moments to open, but subsequent XLookups to the same .db file will be much much faster.

In general, the first XLookup to any .db file will be slow. Subsequent XLookups will be as fast as internal XLookups. So this technique works by moving the first XLookup "out of the way".

This applies to any of the "X" commands.

As an example, try this in Customers.db:

------------------------------------
in GLOBAL CODE:

var str as string

str = @XLookup("c:\Sesame\Data\Samples\ZipCode.db", "Hiram", "xxxxxCity", "Zip Code")
writeln(str)

------------------------------------
in Company ON EXIT

var str as string

str = @XLookup("c:\Sesame\Data\Samples\ZipCode.db", "Hiram", "City", "Zip Code")
writeln(str)

------------------------------------

The XLookup in in GLOBAL CODE will run just before the form opens, effectively "internalizing" the ZipCode.db. Then when you exit the Company LE, the second XLookup will run nearly instanteously.


Mark, back in Feb 2004, you showed technique to speed up xlookup by looking up once in GlobalCode from that particular file once and I guess that kept it open and speed up the consequent lookups commands from that particular file.

Even if you replace the var to stat for variable declaration in GlobalCode that is required after ver 1.1.4 of Sesame, this code does not work and it throws up a lot of other errors along with it. Did something change in the later versions other than declaration of variable as stat in GlobalCode?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Speed up technique does not work anymore
Reply #1 - May 25th, 2007 at 8:16pm
Print Post Print Post  
Quote:
Even if you replace the var to stat for variable declaration in GlobalCode that is required after ver 1.1.4 of Sesame, this code does not work and it throws up a lot of other errors along with it. Did something change in the later versions other than declaration of variable as stat in GlobalCode?


No sign of any problem here. The code compiles (after changing the var to a stat) and runs just fine. Provides the same speed up it always has (because it preloads the external file).
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Speed up technique does not work anymore
Reply #2 - May 25th, 2007 at 8:23pm
Print Post Print Post  
If you have other code in Global Code be sure you place the Variable Declarations at the top before ANY executable code.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Speed up technique does not work anymore
Reply #3 - May 25th, 2007 at 9:09pm
Print Post Print Post  
Well, that leads to something new!! Yes, declaration of stat variable is at the top of other code.  I also have other subroutines and functions in the GlobalCode.  If I put the statement part before any of the subroutines, it throws out errors. If I put the statement part at the end, after all subroutines and functions, it does not cause any error.  Huh
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Speed up technique does not work anymore
Reply #4 - May 25th, 2007 at 9:18pm
Print Post Print Post  
Bharat_Naik wrote on May 25th, 2007 at 9:09pm:
Well, that leads to something new!! Yes, declaration of stat variable is at the top of other code.  I also have other subroutines and functions in the GlobalCode.  If I put the statement part before any of the subroutines, it throws out errors. If I put the statement part at the end, after all subroutines and functions, it does not cause any error.  Huh


The functions and subroutines are a kind of declaration. Executable code must come after all declarations.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Speed up technique does not work anymore
Reply #5 - May 25th, 2007 at 9:24pm
Print Post Print Post  
Got it.  Thanks for clarifying. Good to know that it is a normal behavior.
  
Back to top
 
IP Logged