Some correlated materials display an insulator-to-metal transition as the temperature is increased. In most cases this transition can also be induced electrically, resulting in volatile resistive switching due to the formation of a conducting filament. While this phenomenon has attracted much attention due to potential applications, many fundamental questions remain unaddressed. One of them is its characteristic lengths: what sets the size of these filaments, and how does this impact resistive switching properties. Here we use a combination of wide-field and scattering-type scanning near-field optical microscopies to characterize filament formation in NdNiO3 and SmNiO3 thin films. We find a clear trend: smaller filaments increase the current density, yielding sharper switching and a larger resistive drop. With the aid of numerical simulations, we discuss the parameters controlling the filament width and, hence, the switching properties.