Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Slow SQL data extraction
Message
De
26/07/2001 08:29:40
 
 
À
26/07/2001 05:30:44
Denis Filer
University of Oxford
Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00535574
Message ID:
00535608
Vues:
12
This message has been marked as the solution to the initial question of the thread.
>I have a problem with slow data extraction using SQL. I want to extract records from 'file2' that have codes that match those in 'file1'.
>
>* open a file to extract data from.
>use file2 in 0 alias file2
>
>* this is where the data will go.
>cMyextract = "extract.dbf"
>
>* create an array of key codes from another file (file1) - store in an array
>select distinct keycode from file1 into array myfilecodes
>
>if _tally <> 0
> select * from file2 into DBF &cMyextract where ascan(myfilecodes,keycode) > 0
> use
>endif
>
>I am no expert with SQL. Setting an index on the files doesnt seem to help.
>Especially slow on networks. THANKS!

Create an index on KeyCode in File1. If File2 is large, then an index on KeyCode on File2 will make the following command fully optimizable

In place of creating the array and running multiple SELECTs, issue the following command:
SELECT * FROM File2 ;
  INTO TABLE (cMyExtract) ;
 WHERE KeyCode IN (SELECT KeyCode FROM File1)
Don't bother with creating an array - with your code, there's no optimization taking place, and a relatively expensive ASCAN() is needed to run against each record. The use of the DISTINCT operator is also expensive.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform