Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help to Speed up SQL
Message
 
 
À
13/03/2002 13:36:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00629818
Message ID:
00632278
Vues:
16
You're right, it's slow because it has to process ALL records to calculate SUM() for ALL PK1_Emp_Flag groups. The memory isn't a factor here.

>I think I've figured out that this is where a big part of my problem is. Not enough memory.
>The basic design of the query just uses too much. The sum(t2.field) on so many records uses too much to keep it fast.
>When I applied different filters to reduce the # of records from t1 the query ran fast.
>
>I now have to redesign the data so that I can permanently quit checking to make sure sum(t2.amount) = t1.amount.
>
>Thanks to all who helped.
>
>
>>Try
*To Locate Info to create record 4:
>>Select T2.PK2, T2.PK1, T2.emp, T2.flag ;
>>       T2.PK1_Emp_Flag, - Sum(T2.Amt) as Amt ;
>>    from Table2 T2 ;
>>    WHERE T2.PK1_Emp_Flag NOT IN ( ;
>>       Select T1.PK1_Emp_Flag from Table1 T1 );
>>    GROUP BY T2.PK1_Emp_Flag ;
>>    INTO CURSOR crsRec4
>>
>>*To Locate Info to create records 5 & 6:
>>Select T2.PK2, T2.PK1, T2.emp, T2.flag ;
>>       T2.PK1_Emp_Flag, T1.Amt - Sum(T2.Amt) as Amt ;
>>    from Table2 T2  Join Table1 T1 ;
>>      on T2.PK1_Emp_Flag = T1.PK1_Emp_Flag ;
>>    GROUP BY T2.PK1_Emp_Flag ;
>>    HAVING Amt <> 0 ;
>>    INTO CURSOR crsRec56
>>
>>
>>>I'm current using 5.0a, but trying to find the time to upgrade to 7.0.
>>>
>>>I believe that SQL is my best option here, but certainly open to other ideas.
>>>
>>>My problem is that no matter what I try, the SQL takes too long to find what I'm looking for.
>>>I've tried setting Exclusive on for tables being used.
>>>I've tried adding/removing indexes.
>>>I've tried packing the tables.
>>>The SQL is still taking too long, and getting longer as we add more records.
>>>
>>>
>>>I have 2 tables
>>
>>< snip >
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform