Quantum algorithms for linear systems produce the solution state A−1∣b⟩ by querying two oracles: OA that block encodes the coefficient matrix and Ob that prepares the initial state. We present a quantum linear system algorithm making I^(1/qrtp) queries to Ob, which is optimal in the success probability, and O(I^ºlog(1/p)(loglog(1/p)+log(1/I^µ))) queries to OA, nearly optimal in all parameters including the condition number and accuracy. Notably, our complexity scaling of initial state preparation holds even when p is not known a priori. This contrasts with recent results achieving O(I^ºlog(1/I^µ)) complexity to both oracles, which, while optimal in OA, is highly suboptimal in Ob as I^º can be arbitrarily larger than 1/qrtp. In various applications such as solving differential equations, preparing ground states of operators with real spectra, and estimating and transforming eigenvalues of non-normal matrices, we can further improve the dependence on p using a block preconditioning scheme to nearly match or outperform best previous results based on other methods, which also furnishes an extremely simple quantum linear system algorithm with an optimal query complexity to OA. Underlying our results is a new Variable Time Amplitude Amplification algorithm with Tunable thresholds (Tunable VTAA), which fully characterizes generic nested amplitude amplifications, improves the ℓ1-norm input cost scaling of Ambainis to an ℓ32-quasinorm scaling, and admits a deterministic amplification schedule for the quantum linear system problem.