The question was:
If we state that DROP 1000 instructs the CMS Pipeline to skip the first 1000 records flowing through the pipe, and that the USER DIRECT file contains 6000 records, then, which one of the next examples are not very good for performance, either because it reads too many lines, or because it buffers too much:
1. 'PIPE < USER DIRECT !TAKE 1000!... 2. 'PIPE < USER DIRECT !TAKE LAST 1000!... 3. 'PIPE < USER DIRECT !DROP 5000!... 4. 'PIPE < USER DIRECT !DROP LAST 5000!...
Again an easy one if you think logically.
To take the first 1000, only those 1000 records must be read and no buffering has to take place, just a counter will do.
To be able to TAKE or DROP the last 1000 records, the PIPE has to read the whole file, and to buffer 1000 records of it in storage !
For the 3rd case, the answer is less obvious. We don't know what the rest of the pipeline does. It could be that it just takes 1 record, or that it processes all remaining records. Anyway, the first 5000 records get read, but not buffered. Solution 3 is therefore slightly better than solution 2 and gives the same result.
So, the worst solutions are number 2 and 4.
Use backward navigation to return to the lesson text.