ABSTRACT In order to study the circumgalactic medium (CGM) of galaxies we develop an automated pipeline to estimate the optical continuum of quasars and detect intervening metal absorption line systems with a matched kernel convolution technique and adaptive S/N criteria. We process ∼ one million quasars in the latest Data Release 16 (DR16) of the Sloan Digital Sky Survey (SDSS) and compile a large sample of ∼ 160 000 Mg ii absorbers, together with ∼ 70 000 Fe ii systems, in the redshift range 0.35 < zabs < 2.3. Combining these with the SDSS DR16 spectroscopy of ∼1.1 million luminous red galaxies (LRGs) and ∼200 000 emission line galaxies (ELGs), we investigate the nature of cold gas absorption at 0.5 < z < 1. These large samples allow us to characterize the scale dependence of Mg ii with greater accuracy than in previous work. We find that there is a strong enhancement of Mg ii absorption within ∼50 kpc of ELGs, and the covering fraction within 0.5rvir of ELGs is 2–5 times higher than for LRGs. Beyond 50 kpc, there is a sharp decline in Mg ii for both kinds of galaxies, indicating a transition to the regime where the CGM is tightly linked with the dark matter halo. The Mg ii-covering fraction correlates strongly with stellar mass for LRGs, but weakly for ELGs, where covering fractions increase with star formation rate. Our analysis implies that cool circumgalactic gas has a different physical origin for star-forming versus quiescent galaxies.