Fast writing to a file
Posted in 1994
Topics: Migration, Import/Export & Data Conversion
I'm interested in writing information from Informix-Online 5.01 to files.
Naturally, I want to do it as fast as possible, if not faster. The data
is generally organized as a field and an index, and I want to print out the
data, but not the index, in the order of the index. I'd be interested in your
comments on my thoughts about possible solutions:
1) Using a FOREACH statement:
DECLARE c CURSOR FOR
SELECT my_field, my_index FROM my_table ORDER BY my_index
FOREACH c INTO field_tmp, index_tmp
OUTPUT TO REPORT Print_value(field_tmp)
END FOREACH
PROS: It works, guaranteed
CONS: The FOREACH operation is slower than using a statement that could
perform the entire operation, such as #2 below:
2) Storing the ordered data to a temp table and using an UNLOAD statement:
SELECT my_field, my_index FROM my_table ORDER BY my_index INTO TEMP X
UNLOAD TO "my_file" DELIMITER " " SELECT my_field FROM X
PROS: Potentially faster.
CONS: I don't know that I'm guaranteed that the data will be read out of
the temp table in the same order it's written in. It seems to always
be true for small amounts of data, but is it *guaranteed* to be
true for 100,000 or 1,000,000 records? I'm hesitant to depend on
this behavior because the data absolutely positively has to appear
in the order of the index.
3) Any other potential solutions I've missed?
--
| . . . . . . . . . 1 . . . . . . . . . 2 . . . . . . . . . 3 . . . . . . . . .
GIANTS Francis Small - M/S 2LRS
Bums Hewlett-Packard Company
Rockies Microwave Instruments Div.
Padres 1212 Valley House Dr.
Rohnert Park CA, 94928
707 794 3305
fthes@sad.hp.com
******************** Only 51 days left until Opening Day! *********************