This isn't really a well-defined question as you aren't saying anything about why you might be compresssing the spring to a particular value. However you are probably looking for "Hooke's Law." Hooke's Law deas with "ideal springs." They have no mass and they do not overstretch. If you pull on a real spring too far it will stay extended and Hooke's Law no longer applies to it.