A method for finding a nearly optimal computational grid or, more generally, filter-width distribution for a large eddy simulation is proposed and assessed. The core idea is that the optimal resolution (or coarse-graining length scale, or filter-width, or grid spacing) for LES is the coarsest resolution for which the LES solution is sufficiently accurate and exhibits minimal sensitivity to the resolution. This idea is formulated based on an error indicator that measures the dependence of the solution on the grid/filter as a residual term in the governing equation and a criterion that determines how that error indicator should vary in space and direction to minimize the overall sensitivity of the solution. The final definition of the error indicator becomes very similar to the divergence of the error in the Germano identity, with its derivation offering an alternative explanation for the success of the dynamic procedure. Furthermore, the solution to the optimization problem of grid/filter-width adaptation is that the cell-integrated error indicator should be equi-distributed; a corollary is that one cannot link the accuracy in LES to quantities that are not cell-integrated, including the common belief that LES is accurate whenever 80-90% of the energy is resolved. The full method is tested on wall-resolved LES of turbulent channel flow and the flow over a backward-facing step, with final length scale fields (or filter-width fields, or grids) that are close to what is considered “best practice” in the LES literature.