Optimization question 
Author Message
 Optimization question

Calling all Foxheads:
        I have a Parent-Child relationship, where the child contains many
records, but only an average of 8-10 records per parent. Which is faster
for copying records to arrays?

        A) SELE child
           IF SEEK(parent.key)
                COPY TO ARRAY myArray FIELDS Field1, Field2, .... ;
                 REST WHILE child.key=parent.key
           ENDIF

        B) SELECT Field1, Field2, .... FROM child ;
            WHERE child.key=parent.key ;
            TO ARRAY myArray

        C) Any method that you have that may be faster than both A) and B)

TIA,

Jim



Mon, 21 Jul 1997 10:39:54 GMT  
 Optimization question

Quote:
>Calling all Foxheads:
>    I have a Parent-Child relationship, where the child contains many
>records, but only an average of 8-10 records per parent. Which is faster
>for copying records to arrays?

[code snippets snipped]

Quote:
>    C) Any method that you have that may be faster than both A) and B)

My bet would be on the select, but what do I know?

But, since you asked, I will give you another method...

Since you have a relationship, can you do something like:

<in parent dbf>

SET RELATION TO key INTO child
SET SKIP TO CHILD

<position on the correct parent record>

curkey = key
COPY REST FIELD child.field1, child.field2 ... ;
   TO ARRAY myarray ;
   WHILE key = curkey

Might I assume you ask which is faster (both would be damn quick if they
were only running once) because you are running this section of code for
every parent record?  If so, the above COPY command could take place
inside a SCAN or a DO...WHILE.  It might be faster because you are not
issuing the seek every time, but on the other hands, I have seen the
performance suffer when dbfs are related.

- John
--
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------



Mon, 21 Jul 1997 12:51:54 GMT  
 Optimization question

Quote:

>Calling all Foxheads:
>    I have a Parent-Child relationship, where the child contains many
>records, but only an average of 8-10 records per parent. Which is faster
>for copying records to arrays?

>    A) SELE child
>       IF SEEK(parent.key)
>            COPY TO ARRAY myArray FIELDS Field1, Field2, .... ;
>             REST WHILE child.key=parent.key
>       ENDIF

>    B) SELECT Field1, Field2, .... FROM child ;
>        WHERE child.key=parent.key ;
>        TO ARRAY myArray

that would be:

  SELECT Field1, Field2, ... ;
  FROM child, parent ;
  INTO ARRAY myArray ;
  WHERE child.key = parent.key

Assuming the fields are all from the child table, when translated means:

give me Field1, Field2, ... from the child table if there is a record
in the parent table with a matching value in field 'key'.

-- Tim

--
\_\_\_\_\_   \_\_\_\_   \_    \_    \_
     \_       \_    \_    \_   \_\_  \_
      \_       \_\_\_       \_  \_ \_ \_
       \_       \_    \_      \_     \_   ><_>



Sat, 26 Jul 1997 03:43:09 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. optimization

2. Optimization

3. FoxPro 2.6 for DOS, code optimization

4. Rushmore optimization ?

5. JOIN Optimization

6. Query Optimization

7. Help with optimization

8. VFP Rushmore optimization not kicking in

9. Search optimization

10. SQL statement optimization

11. Cutting Length Optimization

12. Query Optimization

 

 
Powered by phpBB® Forum Software