Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any ideas on speeding up this query
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01284133
Message ID:
01284164
Vues:
20
Try
SELECT Ordprod.orderid, Ordsize.orderprodid,;
  SUM(Ordsize.ordered) AS totordered,;
  SUM(Ordsize.allocated) AS totallocated,;
  SUM(Ordsize.shipped) AS totshipped, .T. AS specialord;
 FROM ;
     Ordsize ;
    INNER JOIN ordprod ;
   ON  Ordprod.orderprodid = Ordsize.orderprodid ;
   where OrdPro.orderid in (select orderid from OrderHead where SBO = .T.)
   GROUP BY Ordsize.orderprodid, Ordprod.orderid
 union all ;
 SELECT Ordprod.orderid, Ordsize.orderprodid,;
  SUM(Ordsize.ordered) AS totordered,;
  SUM(Ordsize.allocated) AS totallocated,;
  SUM(Ordsize.shipped) AS totshipped, .F. AS specialord;
 FROM ;
     Ordsize ;
    INNER JOIN ordprod ;
   ON  Ordprod.orderprodid = Ordsize.orderprodid ;
   where OrdPro.orderid in (select orderid from OrderHead where SBO = .F.)
   GROUP BY Ordsize.orderprodid, Ordprod.orderid 
 ORDER BY 2
Or same with where EXISTS()


>I have used the coverage profiler and found that the slowest line of code is when this view is requeried.
>
>
>SELECT Ordprod.orderid, Ordsize.orderprodid,;
>  SUM(Ordsize.ordered) AS totordered,;
>  SUM(Ordsize.allocated) AS totallocated,;
>  SUM(Ordsize.shipped) AS totshipped, Ordhead.sbo AS specialord;
> FROM ;
>     Ordsize ;
>    INNER JOIN ordprod ;
>   ON  Ordprod.orderprodid = Ordsize.orderprodid ;
>    INNER JOIN ordhead ;
>   ON  Ordprod.orderid = Ordhead.orderid;
> GROUP BY Ordsize.orderprodid, Ordprod.orderid, Ordhead.sbo;
> ORDER BY Ordsize.orderprodid
>
>
>This view returns about 20,000 records
>
>ordsize table has 194,000 records
>ordprod table has 21,000 records
>ordhead table has 3600 records
>indexes exist for all fields, i.e. orderprodid,orderid in all tables
>
>This query takes about 2-3 seconds on my local machine, but can take minutes over the network at the customer site.
>
>Any ideas on how to speed this up?
>Mike
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