http://sparrowa7io5pz6ud3ehqzosvepbxbxt2zphmkjsylp2zgxooko23pqd.onion/docs/server-performance.html
For example, the txid is determined from a logical file containing all txids in blockchain order, where the offset in the file is simply the tx_num * 32 bytes (the size in bytes of a SHA256 hash).
Similarly, Fulcrum and ElectrumX keep an array in memory where each index corresponds to the blockheight, and the value at that index contains the cumulative number of transactions that existed at that height.