An optimization method is used to obtain the longest effective afterglow time in the rare earth ions doped long lasting phosphors. The effective afterglow time is defined as the time for the intensity to decays to 10% of the initial intensity. In this paper, we choose the Eu<sup>2+</sup> and Dy<sup>3+</sup> coped Sr<sub>2</sub>MgSi<sub>2</sub>O<sub>7</sub> as the experimental objects. In order to obtain the longest effective afterglow time of Sr<sub>2</sub>MgSi<sub>2</sub>O<sub>7</sub>:Eu<sup>2+</sup>, Dy<sup>3+</sup> phosphor, the experiment is optimized by quadratic general rotation combination design. The Sr<sub>2</sub>MgSi<sub>2</sub>O<sub>7</sub>:Eu<sup>2+</sup>, Dy<sup>3+</sup> phosphor are synthesized via a solid-state reaction. The effective afterglow time is obtained by the afterglow decay curve. A binary quadratic regression equation model relating the rare earth ions Eu<sup>2+</sup>/Dy<sup>3+</sup> doping concentrations to the effective afterglow time is established. The genetic algorithm is used to solve the equation. The optimal doping concentration of Eu<sup>2+</sup> and Dy<sup>3+</sup> are 0.5 mol% and 1.0 mol%, respectively. The theoretical maximum value of effective afterglow time is calculated to be 321 s. The phosphor with the optimal doping concentration Sr<sub>2</sub>MgSi<sub>2</sub>O<sub>7</sub>:0.5 mol% Eu<sup>2+</sup>, 1.0 mol% Dy<sup>3+</sup> are synthesized by the same method as that of synthesizing the frontal samples. The X-ray diffraction shows that the optimal sample prepared is of pure phase, and the doping ions have no effect on the lattice structure of the matrix. A characteristic emission at 465 nm due to the 4f<sup>6</sup>5d<sup>1</sup>−4f<sup>7</sup> transition of Eu<sup>2+</sup>is observed under the 370 nm excitation. The afterglow curve of the optimal sample is measured and the effective afterglow time is 333 s which has a good match with the theoretically calculated value of 321 s. The thermoluminescence spectrum of the optimal phosphor is measured, and the trap depth is calculated to be 0.688 eV according to the Chen’s model. Moreover, the long-lasting luminescence process of Eu<sup>2+</sup> as the luminescence center of Sr<sub>2</sub>MgSi<sub>2</sub>O<sub>7</sub> matrix is discussed in the energy level diagram.