1 |
> My generic question is: When I'm using a pipe line series of commands |
2 |
> do I use up more/less space than doing things in sequence? |
3 |
|
4 |
When you use a pipe you don't need the space to store intermediate |
5 |
results between the two programs. Thepipe is backed by a small |
6 |
system-allocated RAM buffer (4k under linux AFAIK) and program execution |
7 |
is controlled according to the amount of data in the buffer. |
8 |
|
9 |
Not having to save intermediate results generally means that you will |
10 |
need less disk space: this is especially true in the mysqldump-gzip |
11 |
example as the uncompressed dump will not be written to the disk at any |
12 |
stage. |
13 |
|
14 |
Note however (this is the "it depends" part :) that piping does not |
15 |
affect whatever the programs might allocate or save internally: in your |
16 |
second example (which does not involve any disk writing in either case) |
17 |
"sort" needs to see the complete input before producing any output, so |
18 |
it will allocate enough memory to store it whether it is invoked alone |
19 |
or as part of a pipeline (in which case it will also stall the |
20 |
downstream pipeline section until the upstream pipe is closed). |
21 |
|
22 |
HTH, |
23 |
andrea |