Closed quentinlesceller closed 4 years ago
That's strange. On my cheap box running grinexplorer.net that query takes "just" 2s. Can you please do an EXPLAIN ANALYZE
for me? I'm curious to see how our two execution plans differ.
It's indeed missing an index though, please do:
CREATE INDEX ON blockchain_block (timestamp);
ANALYZE blockchain_block;
and then do the EXPLAIN ANALYZE
again. That new index gave me a speedup of ~10.
Another thing that's not optimal is that hash
, the pkey, is a text
and is used for the lookup in the JOIN statement. We should consider two changes: changing the hash to bytea
and/or use a numeric pkey (instead of the hash). I'll open issue for these once we've looked at your specific issue.
Okay massive speedup with the new index. Thanks @hendi !!!
I've noticed a heavy load on our database simply to display the list of blocks. The query is the following:
This query is extremely expensive and very slow even on a powerful db (like 10s to compute). I am wondering whether we are missing an index somewhere.
Here is the table description:
@hendi any idea?