Provided is a magnetic disk device capable of efficiently searching for commands. According to the present embodiment, a magnetic disk device includes a magnetic disk, a memory, and a controller. The disk includes a plurality of regions to which unique addresses are assigned, respectively. The memory stores a plurality of unprocessed commands. The controller stores a
database of a tree-like structure in a memory. The configuration includes a plurality of nodes associated with each of a plurality of addresses specified by each of a plurality of unprocessed commands, and two of the plurality of nodes are associated with each other. The controller selects a candidate command from a command associated with an address larger than the start address and closest to the start address and a command associated with an address smaller than the start address and closest to the start address, the candidate command being a candidate to be executed next among the plurality of unprocessed commands.