Implementation of getdata I am confused about how getdata() is actually implemented at full nodes.

Suppose a full node receives a getdata() request with MSG_BLOCK flag and a hash H of some block B. Then would it simply look up H into its levelDB database to fetch B from its disk and return it to the caller (in constt time) or something more expensive is done?

Can I also get some references to read about it?
There isn't even a database lookup in Bitcoin Core. All blocks and mempool transactions are indexed by hash in memory. It's typically just serializing from memory, or one disk read directly sending disk data to the network.