General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Hello Kevin
If your child table has an index set which is likely then the records only appear to be grouped together so in effect multiple record pointer movements are taking place during your first method.
Also, I don't have your data set to try this test with, but I did notice that you are using a DO WHILE in one condition and a SCAN in the other. Scan is a little bit faster.
Do you have any relationships set on the child table, that of course would make a big difference.
>I have been debating on child records, whether to SELECT the related records
or SEEK and SKIP through them.
>
>I have always regarded the SEEK as the fastest method, but have usually run SELECT INTO CURSOR, and then SCAN the cursor.
>
>I ran a simple test and the SELECT came out quicker - can this be right.
>
>Here are my 2 methods:
>
>*** SEEK Method ***
>
>SELECT ChildTable
>IF SEEK(ParentTable.PriKey)
>DO WHILE ChildTable.ForKey = ParentTable.PriKey
>**** Some Code Here ****
>SKIP
>ENDDO
>*******************
>
>*** SELECT Method ***
>
>SELECT * FROM ChildTable;
>WHERE ForKey = ParentTable.PriKey;
>INTO CURSOR Cursor1
>
>SELECT Cursor1
>SCAN
>**** Some Code Here ****
>ENDSCAN
>*********************
>
>
>Could someone advise me if this is correct - why would the SEEK be slower if the SELECT has to input the Query into a CURSOR and then SCAN?
>
>Replies much appreciated
>Thanks
>Kev
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only