Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is SELECT ... IN (subquery) Optimized?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00557577
Message ID:
00557613
Vues:
9
>Hi Everyone,
>
>This query returns no records:
>
>  SELECT gen.file_id ;
>  FROM datatrac!gen gen  ;
>  WHERE gen.trade_no = 0 .AND. (gen.app_date >= DATE()-30) ;
>  INTO CURSOR tmp_cur1 NOFILTER
>
>This query takes 50 seconds to execute:
>
>  SELECT gen.int_rate ;
>  FROM gen ;
>  WHERE gen.file_id IN (SELECT file_id FROM tmp_cur1) INTO CURSOR tmp_cur2
>
>Because the first query has NO records and because it's taking 50 seconds, my assumption is that the 2nd query is not optimized. Does anybody know if SELECT ... IN (subquery) is unoptimized IN VFP 6.0?
>
>Please help if you can. Thank you. Good to see all of you at the DevCon. Need to update my picture. I think that's from highschool! :)
>
>Shawn Nelson

Here is what should give you the same result:
>  SELECT gen.file_id ;
>  FROM datatrac!gen gen  ;
>  WHERE gen.trade_no = 0 .AND. (gen.app_date >= DATE()-30) ;
>  INTO CURSOR tmp_cur1 NOFILTER
   index on file_id tag file_ID


>  SELECT gen.int_rate ;
>  FROM gen ;
>  INNER JOIN tmp_cur1 on gen.File_ID=tmp_cur1.File_ID ;
   INTO CURSOR tmp_cur2
BTW, you can check _tally after first select and not execute it at all, if the first returns 0 records.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform