Where does “goodness me” come from?

The expression “my goodness” always seemed clear to me, as it is a simple bowdlerisation of “my God”, as are many expletives. However, I have heard many times the expression “goodness me!”, which Google confirms exist (and is less used than “my Goodness”):

ngram

This expression doesn't make any sense to me on the construction. Goodness is a noun, so why is it formed that way? Is it an alteration of “my goodness”, or was it formed somewhat independently? Is it a shortening of a longer expression, which would explain its weird grammatical form?


I believe it is a shortening of the phrase goodness gracious me which I think is a mincing of the oath God grace me, which would be a request for God's help.

This is because part of the etymology of gracious is

filled with God's grace

Shortening phrases is something typical of English, and has left us with three other minces:

  1. Goodness gracious
  2. Goodness me
  3. Gracious me