Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Performance issues when querying shared data
Message
De
07/10/2005 11:43:15
Jim Winter
Jim Winter Consulting
Hinesburg, Vermont, États-Unis
 
 
À
07/10/2005 11:03:12
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 6
Divers
Thread ID:
01057091
Message ID:
01057210
Vues:
10
>>>Well,
>>>
>>>The initial query is:
>>>
>>>Select a.field1 As Code, a.Field2 As Desc From TableA a Into Cursor tmpCursor
>>>
>>>The table has an index on field1 so I added:
>>>
>>>where a.Field1 = ""
>>>
>>>It's a cheat I know but the query is optimised and works as long as set exact off.
>>>
>>>The time jumps from 5 secs to under 2.
>>>
>>
>>Hi Mathias,
>>
>>That is too cool! I just tested it on my setup and got similar results.
>>
>>Thanks,
>
>I'm not getting what is happening here. What is the 'where a.Field1 = ""' helping do? What is the test and the comparison?

Jay,
*Test1.prg
LOCAL nStart
nStart = SECONDS()
SELECT ItemNo, InvoNum FROM ARSTrans
?SECONDS() - nStart
*Result = 33.469 seconds

*Test2.prg
LOCAL nStart
nStart = SECONDS()
SELECT ItemNo, InvoNum FROM ARSTrans WHERE ItemNo = ''
?SECONDS() - nStart
*Result = 23.494 seconds

*Test3.prg
LOCAL nStart
nStart = SECONDS()
SELECT ItemNo, InvoNum FROM ARSTrans ORDER BY 1
?SECONDS() - nStart
*Result = 37.203 seconds

*Test4.prg
LOCAL nStart
nStart = SECONDS()
SELECT ItemNo, InvoNum FROM ARSTrans WHERE ItemNo = '' ORDER BY 1
?SECONDS() - nStart
*Result = 26.532 seconds
All 4 programs were run separately from separate instances of VFP to avoid memory cache affecting the results.

The key is to use a character field with an index because VFP only compares the expression on the left up to the length of expression on the right. Thus VFP fully optimizes the query but doesn't actually do any string comparison and returns all the records, or so it seems.

Regards,
Jim
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform