Retrieve number of OP-RETURN transaction
For statistics you’re best using bitcoin-iterate which will let you extract information very quickly. Here you want to be searching for scripts beginning with the op return byte, it takes only tens of minutes to search the whole chain from disk.