File format · .s$$

Temporary Sort File: What It Is, Why It Breaks, and How to Recover It

A plain-language guide to temporary sort files: which programs create them, why they are left behind or damaged, and what can be recovered.


A temporary sort file is a scratch file a program creates while it sorts data. The plan is always the same: build it, use it, delete it. Trouble starts when the middle step fails. A job that dies halfway leaves a partial file behind, and that file can look like a corrupt document you never meant to keep. This page explains what these files are, why they break, and what can be salvaged from one.

What is a temporary sort file?

Sorting is easy while the data fits in memory. When it does not, the program switches to an external sort: it sorts blocks that do fit, writes each finished block to disk as a sorted run, and merges the runs into one result at the end. The temporary files on disk are those runs. This two-phase design, sort then merge, is the standard way software handles a data set larger than physical memory.

Which programs create sort work files?

Any software that can sort more rows than memory allows. The common cases include server databases such as PostgreSQL, MySQL, SQL Server, and Oracle. Desktop databases and accounting packages write them too, as do report and payroll tools that sort before printing. Command line utilities join in; the Unix sort command is the classic example, and it lets you choose the spill directory.

The files usually land in the system temporary folder, %TEMP% on Windows or /tmp on Linux, or in a database's own temporary storage area. Names are mostly random, and extensions vary: .tmp, .sort, or none at all.

Inside the file: what a sorted run looks like

There is no universal signature for a sort file, because the content mirrors whatever the program was sorting. A text sort produces runs of readable lines in order. A database sort writes records in the table's own layout, sometimes with the sort key stored alongside, sometimes compressed or packed into vendor-specific pages.

One property holds in nearly every case: the file is a sequence of runs, each run sorted on its own, and the final merge reads them together. A job cut off mid-merge leaves complete runs followed by a short, partial one.

Why do temporary sort files cause problems?

Most sort files die for boring reasons. The disk fills up mid-write and the program cannot finish the current run. Power fails, or the machine is forced off, while the merge is under way. An overnight job is cancelled, and the cleanup code never runs. Housekeeping tools or antivirus software delete a file the program still needs. None of this touches your original data; the source rows are usually exactly where you left them.

The awkward case is rarer but real. Sometimes the scratch file holds the only complete copy of the result: the input was a pipe or a live feed, the original list has since been deleted or overwritten, or the job was writing its final output when it died. Then the leftover run file stops being rubbish and starts being evidence.

What can be recovered from a damaged sort file?

More than you might expect. Because each run is written start to finish before the next one begins, a truncated file usually contains several complete runs. If the layout is text, recovery can be as simple as reading the lines. If it is binary, we identify the record boundaries, work out the field layout from the sorted order, and rebuild the rows. The final partial run is salvaged up to the point where writing stopped.

Expect two honest limits. Records in the unfinished tail may be incomplete and have to be discarded. And if the runs were compressed in a format we cannot map, the content stays out of reach until we can compare against a healthy file from the same software and version.

How do we recover the data?

Every job starts the same way. You send us a copy; we never work on your only file. Our engineers examine the bytes, confirm what program made the file, and map the run structure. We re-merge the runs in order, repair broken records where possible, and export the result to a format you can open, such as a spreadsheet or CSV. You get a report of what came back, and what did not, before you decide to go ahead.

Frequently asked questions

Is it safe to delete an old sort file?

If the program that created it is closed, usually yes. Check the date: files from today may belong to a job still running. Deleting one mid-sort will break that job.

Can I just sort the original data again?

If the source still exists, yes, and that is always the cheaper option. Repair is for the case where the scratch file is the only copy of the result.

Why does the same file keep reappearing?

The program recreates it every time the same job runs. A file that grows by gigabytes each week points at a sort that needs a smaller batch, a tighter filter, or more memory.

Can I open one in a text editor?

Text sorts will show readable, roughly ordered lines. Binary or compressed runs will look like noise. Look, do not edit: saving from an editor can alter the file and make proper recovery harder.

Our team handles damaged sort and scratch files from most database, accounting, and office software. If a leftover sort file is your only copy of the data, send it to us for a free evaluation. We will tell you what is recoverable before you spend anything.

Send us your .s$$ file for a free evaluation

Our recovery engineers will tell you exactly what can be recovered — at no cost. There is no charge if we cannot recover your data.

Start a free evaluation