Search | Synergex.com | Contact Us | Resource Center Login | Home|
News

What is the most efficient way to sort a sequential file containing 12,000 records of 1024 bytes each?

a. Read the records into an array and use XCALL QSORT

b. Use the SORT command

c. Create an ISAM file with the appropriate key structure, and load it using a READS/STORE loop

d. Spawn the fconvert utility to create an ISAM file from the sequential file

Explanation:
The correct answer may depend on how you need to use the records once they’re sorted. Since we didn’t specify that, we’ll assume the best case final form for each of the above. Thus, for QSORT, we’ll leave the records in memory, for SORT they’ll be in a second sequential file, and for the last two options they’ll be in a Synergy DBMS (aka ISAM) file. Given that, the SORT command (b) wins. It’s nearly twice as fast as its nearest competitor, QSORT (a). If the records had already been in memory, though, QSORT can be faster, depending on the logic in its user-supplied function. The fconvert utility (d) is a very fast way to convert a sequential file to Synergy DBMS.

In this example, using fconvert is about three times faster than storing the records. For larger files, fconvert can be up to 100 times faster than a reads/store loop (c), even with the overhead of creating a new process. But unless you need to have key-based access to the records, the combination of SPAWN and fconvert is still about eight times slower than SORT in this scenario. Your mileage may vary.

This example shows how Synergy/DE provides multiple options to meet your specific needs. Depending on where your data is coming from and how you’ll need to use it, you can choose the best tool for the job. If the data is already in a sequential file and you will only need to access it in sequential key order, then use SORT. If it is already entirely in memory or will need to be, then QSORT may work best. If you will need key-based random access to the result, then convert it to a Synergy DBMS file.


More information about News and Events

Contact Synergex to learn more about  News and Events