You can setup a fixed uniform layout that you don’t have to query per program if you use uniform buffer object with std140 layout. see also OpenGL wiki page.
Using uniform buffers can also improve performance, but they need a bit more work from the application.
You still have to use glGetUniformBlockIndex to get the uniform block’s index. However, once you set the binding point with glUniformBlockBinding, you won’t need to set either one again (assuming you always use the same binding point for this program). So it is still helpful.