Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I optimize the intermediate result
Message
From
08/06/2001 19:52:27
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
To
08/06/2001 18:49:33
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00517267
Message ID:
00517271
Views:
15
Dan,

You've talked about the optimization level, but you haven't talked about the percieved speed of your code.

Indexing on DELETED() may make the optimization show as "Fully optimized" but it may actually be slower than not having an index on DELETED(). In general, you are better off NOT indexing on fields which have only a few discrete values, such as DELETED or gender. There was a FoxPro Advisor article about this which explained exactly why.

My impression is that your indexing strategy is correct, as far as it goes. You might, however, increase speed by causing VFP to make a temporary table on the first pass by doing:
Select *, <b>.F. AS AddedField</b> ;
    From Invoice ;
    Where ;
        InvoiceId = 3 And ;
        Between( InvoiceDate, {12/01/01}, {12/31/01} ) ;
    Into Cursor qInvoices

*!* You may not need to index qInvoices
*!* Since I think you only need to index the child table. Test to be sure.
*!* Index On InvoiceId Tag InvoiceId

Select ;
       qInvoices.*, ;
       InvoiceDetail.Amount ;
    From qInvoices ;
        Inner Join InvoiceDetail On ;
        qInvoices.InvoiceId = InvoiceDetail.InvoiceId ;
    Into Table InvoiceAmounts
>Sorry hit submit by mistake
>
>>Here is sample code to illustrate the point.
>
>Sys(3054,11)
>
>Select * ;
>    From Invoice ;
>    Where ;
>        InvoiceId = 3 And ;
>        Between( InvoiceDate, {12/01/01}, {12/31/01} ) ;
>    Into Cursor qroInvoices
>
>Use Dbf("qroInvoices") Again In 0 Alias qInvoices
>Select qInvoices
>Index On InvoiceId Tag InvoiceId
>
>Select ;
>       qInvoices.*, ;
>       InvoiceDetail.Amount ;
>    From qInvoices ;
>        Inner Join InvoiceDetail On ;
>        qInvoices.InvoiceId = InvoiceDetail.InvoiceId ;
>    Into Table InvoiceAmounts
>
>
>I have an index on InvoiceDate I have an index on InvoiceId in both the Invoice and InvoiceDetail. I have an index on Deleted() in both the Invoice and InvoiceDetail.
>
>Everything shows as fully optimized but one line which states:
>Rushmore Optimization level for intermediate result: None
>
>What do I need to do to get full optimization for the intermediate result?
>
>TIA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform