Note: this is all written with the best intentions, no offence, a good discussion is educational, everybody learns, it's christmas etc etc...
Ok, let's get back to reality here.
The original question was "how can I get the new value for the SERIAL column after I insert a new record?"
The simplest and most efficient way to do this is by use pg_getlastoid(). Simply because that is returned immediately by the database engine and requires no extra query.
"I think that asking for the key first and using it for the insert is the fastest way to do the job."
When did doing extra work start making things faster?
"if you insert the record, and then you execute the select using the OID as the condition, the server has to use the index to do the search, and the index pages may not be in memory."
That's the point, there is no select, only an insert. (btw index pages not in memory? which databases server would ever take the index out of memory?)
"anyway, we are talking bout very extreme cases. For regular database work both methods will work just fine."
With all due respect: that is nonsense.
The fact that you are doing it on a small scale is no excuse for doing it 'wrong'.
That's how Microshit got into trouble.