To improve the filtering performance of a heterostructure photonic crystal ring resonator filter, the filtering structural parameters were optimized globally by using particle swarm optimization (PSO) algorithm. By taking the square lattice photonic crystal ring resonator filter structure as the optimized object, according to the position-velocity updating formula of the PSO method, the radius of scattering rods, coupling rods, and internal rods at the photonic crystal defect were optimized globally. From the theoretical analysis and numerical simulation results, it can be seen that after the filter structural parameters were optimized, single narrowband filtering can be achieved. At the same time, its normalized transmission rate is increased from 53% to 97%, indicating the effectiveness of the optimization algorithm, which provides a basis for the application in photoelectric device.