Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to speed this loop and/or SQL up?
Message
De
18/03/2005 11:42:37
 
 
À
18/03/2005 11:37:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00997258
Message ID:
00997298
Vues:
13
>>If you have an index on the combined expression, a SEEK on the combined expression would be extremely fast. On the other hand, this index would not be used to optimize the SELECT statement as you posted it. For example, an index on Field1 + Field2 would only be used if you include a WHERE Field1 + Field2 = ...". IOW, the index has to exactly match part of the WHERE clause, or all of it.
>>
>>>Well, as there could be many J rec's with the same RTE_NO + RTE_LET + DIRECTN (c.f. Composite PK), but, of course, incrementally differnnet SEQNOs, do you mean I should knock off the PK?
>>
>>No, apart from the fact that you need it, the primary key has unique value, and will cause no problem. I mean to knock of indices that have only a few possible values.
>
>So now I've changed it to:
>
>
>...
>Set Order To RGDSNum   && RTE_NO + RTE_LET + DIRECTN + STR(SEQNO,4) + STR(NUMBER,3)
>...
>SCAN
>  lcRteNo	         = PADR( RTE_NO, 6)
>  lcDirectn	= DIRECTN
>  lnSeqNo	         = SEQNO
>  lnNumber	= NUMBER
>  lcStopNo	= PADR( STOP, 8)
>  lcCounty	= PADR( COUNTY, 2)
>
>  Select DISTINCT TIME from	RZStop ;
>  	where 	PADR( RZStop.RTE_NO, 6)     == lcRteNo ;
> 	  and   RZStop.RTE_LET		== "A" ;
> 	  and 	RZStop.DIRECTN		== lcDirectn ;
> 	  and	STR( RZStop.SeqNo, 4)	== lcSeqNo ;
>	  and	STR( RZStop.Number, 3)	== lcNumber ;
>	  and	PADR( RZStop.Stop, 8)	== lcStopNo ;
>	  and	PADR( RZStop.County, 2)	== lcCounty ;
> 	  and	not EMPTY( RZStop.TIME) ;
>  to SCREEN NOCONSOLE	&& Find any time value for this particular stop across all other sequences
>  If _TALLY = 0			&& no hits on this stop # - i.e. all Time values empty
>      ...
>
>
>... and it does indeed go like sh*t off a chrome shovel, that's been lubricated with buckminster fullerase :-).
>
>I get no reported anomolies in my error report table (which is toi be expected but I'm not sure if it is correct). But the main thing is it goes through the whole cursor super-fast, does each SQl and gets out without a C5.
>
>So way to go, Hilmar and thanks very much. I'll be looking at the import app's other loops now to see if I can optimise similarly.
>
>Terry

With the PADR(zz,x) expression, there is no need for the dounle equal signs, a single equal sign will give the same result. But it won't hurt either.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform