Optimization question
Author Message
Optimization question

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:
>    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

<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:

>    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

 Page 1 of 1 [ 3 post ]

Relevant Pages