Skip to content

Fee stats API takes too much time #244

@cubistplay

Description

@cubistplay

For TransferAsset

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=366113.38..366136.71 rows=200 width=22024) (actual time=387.693..394.615 rows=200 loops=1)
   ->  Gather Merge  (cost=366113.38..369923.74 rows=32658 width=22024) (actual time=387.692..394.592 rows=200 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         ->  Sort  (cost=365113.35..365154.17 rows=16329 width=22024) (actual time=379.665..379.702 rows=91 loops=3)
               Sort Key: "Transaction"."blockNumber" DESC, "Transaction"."transactionIndex" DESC
               Sort Method: external merge  Disk: 24896kB
               ->  Hash Left Join  (cost=1221.72..56334.72 rows=16329 width=22024) (actual time=9.071..335.636 rows=13344 loops=3)
                     Hash Cond: (("Transaction".hash)::text = (custom."transactionHash")::text)
                     ->  Hash Left Join  (cost=1210.14..56280.28 rows=16329 width=20972) (actual time=9.053..326.089 rows=13344 loops=3)
                           Hash Cond: (("Transaction".hash)::text = (remove."transactionHash")::text)
                           ->  Hash Left Join  (cost=1199.02..56226.29 rows=16329 width=19408) (actual time=9.040..317.207 rows=13344 loops=3)
                                 Hash Cond: (("Transaction".hash)::text = (store."transactionHash")::text)
                                 ->  Hash Left Join  (cost=1188.34..56172.75 rows=16329 width=17328) (actual time=9.028..308.476 rows=13344 loops=3)
                                       Hash Cond: (("Transaction".hash)::text = ("setShardUsers"."transactionHash")::text)
                                       ->  Hash Left Join  (cost=1175.42..56116.96 rows=16329 width=16760) (actual time=9.016..300.048 rows=13344 loops=3)
                                             Hash Cond: (("Transaction".hash)::text = ("setShardOwners"."transactionHash")::text)
                                             ->  Hash Left Join  (cost=1162.49..56061.18 rows=16329 width=16192) (actual time=9.004..291.551 rows=13344 loops=3)
                                                   Hash Cond: (("Transaction".hash)::text = ("createShard"."transactionHash")::text)
                                                   ->  Hash Left Join  (cost=1149.57..56005.39 rows=16329 width=15624) (actual time=8.985..283.183 rows=13344 loops=3)
                                                         Hash Cond: (("Transaction".hash)::text = ("setRegularKey"."transactionHash")::text)
                                                         ->  Nested Loop Left Join  (cost=1102.44..55915.40 rows=16329 width=15411) (actual time=8.747..274.090 rows=13344 loops=3)
                                                               ->  Nested Loop Left Join  (cost=1102.03..44098.88 rows=16329 width=15281) (actual time=8.725..209.855 rows=13344 loops=3)
                                                                     ->  Hash Left Join  (cost=1101.62..33269.84 rows=16329 width=14231) (actual time=8.681..154.180 rows=13344 loops=3)
                                                                           Hash Cond: (("Transaction".hash)::text = ("wrapCCC"."transactionHash")::text)
                                                                           ->  Hash Left Join  (cost=247.62..32372.98 rows=16329 width=14005) (actual time=2.283..137.943 rows=13344 loops=3)
                                                                                 Hash Cond: (("Transaction".hash)::text = ("increaseAssetSupply"."transactionHash")::text)
                                                                                 ->  Hash Left Join  (cost=236.95..32319.45 rows=16329 width=11317) (actual time=2.272..130.587 rows=13344 loops=3)
                                                                                       Hash Cond: (("Transaction".hash)::text = ("changeAssetScheme"."transactionHash")::text)
                                                                                       ->  Hash Left Join  (cost=226.50..32266.13 rows=16329 width=8617) (actual time=2.259..123.599 rows=13344 loops=3)
                                                                                             Hash Cond: (("Transaction".hash)::text = ("decomposeAsset"."transactionHash")::text)
                                                                                             ->  Hash Left Join  (cost=215.15..32211.92 rows=16329 width=7473) (actual time=2.248..117.120 rows=13344 loops=3)
                                                                                                   Hash Cond: (("Transaction".hash)::text = ("composeAsset"."transactionHash")::text)
                                                                                                   ->  Nested Loop Left Join  (cost=204.92..32158.83 rows=16329 width=3145) (actual time=2.229..110.616 rows=13344 loops=3)
                                                                                                         ->  Hash Left Join  (cost=204.51..9309.63 rows=16329 width=1472) (actual time=2.186..27.899 rows=13344 loops=3)
                                                                                                               Hash Cond: (("Transaction".hash)::text = ("mintAsset"."transactionHash")::text)
                                                                                                               ->  Parallel Seq Scan on "Transactions" "Transaction"  (cost=0.00..9062.26 rows=16329 width=458) (actual time=0.021..19.110 rows=13344 loops=3)
                                                                                                                     Filter: ((NOT "isPending") AND ((type)::text = 'transferAsset'::text))
                                                                                                                     Rows Removed by Filter: 36559
                                                                                                               ->  Hash  (cost=177.56..177.56 rows=2156 width=1014) (actual time=2.112..2.112 rows=2155 loops=3)
                                                                                                                     Buckets: 4096  Batches: 1  Memory Usage: 1082kB
                                                                                                                     ->  Seq Scan on "MintAssets" "mintAsset"  (cost=0.00..177.56 rows=2156 width=1014) (actual time=0.009..0.936 rows=2155 loops=3)
                                                                                                         ->  Index Scan using "TransferAssets_pkey" on "TransferAssets" "transferAsset"  (cost=0.41..1.40 rows=1 width=1673) (actual time=0.005..0.005 rows=1 loops=40031)
                                                                                                               Index Cond: (("Transaction".hash)::text = ("transactionHash")::text)
                                                                                                   ->  Hash  (cost=10.10..10.10 rows=10 width=4328) (actual time=0.004..0.004 rows=0 loops=3)
                                                                                                         Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                                                                                         ->  Seq Scan on "ComposeAssets" "composeAsset"  (cost=0.00..10.10 rows=10 width=4328) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                             ->  Hash  (cost=10.60..10.60 rows=60 width=1144) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                                   Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                                                                                   ->  Seq Scan on "DecomposeAssets" "decomposeAsset"  (cost=0.00..10.60 rows=60 width=1144) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                       ->  Hash  (cost=10.20..10.20 rows=20 width=2700) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                             Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                                                                             ->  Seq Scan on "ChangeAssetSchemes" "changeAssetScheme"  (cost=0.00..10.20 rows=20 width=2700) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                 ->  Hash  (cost=10.30..10.30 rows=30 width=2688) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                       Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                                                                       ->  Seq Scan on "IncreaseAssetSupplies" "increaseAssetSupply"  (cost=0.00..10.30 rows=30 width=2688) (actual time=0.003..0.003 rows=0 loops=3)
                                                                           ->  Hash  (cost=668.44..668.44 rows=14844 width=226) (actual time=6.340..6.340 rows=14870 loops=3)
                                                                                 Buckets: 16384  Batches: 1  Memory Usage: 3962kB
                                                                                 ->  Seq Scan on "WrapCCCs" "wrapCCC"  (cost=0.00..668.44 rows=14844 width=226) (actual time=0.008..2.425 rows=14870 loops=3)
                                                                     ->  Index Scan using "UnwrapCCCs_pkey" on "UnwrapCCCs" "unwrapCCC"  (cost=0.41..0.66 rows=1 width=1050) (actual time=0.003..0.003 rows=0 loops=40031)
                                                                           Index Cond: (("Transaction".hash)::text = ("transactionHash")::text)
                                                               ->  Index Scan using "Pays_pkey" on "Pays" pay  (cost=0.42..0.72 rows=1 width=130) (actual time=0.004..0.004 rows=0 loops=40031)
                                                                     Index Cond: (("Transaction".hash)::text = ("transactionHash")::text)
                                                         ->  Hash  (cost=41.50..41.50 rows=450 width=213) (actual time=0.224..0.224 rows=468 loops=3)
                                                               Buckets: 1024  Batches: 1  Memory Usage: 122kB
                                                               ->  Seq Scan on "SetRegularKeys" "setRegularKey"  (cost=0.00..41.50 rows=450 width=213) (actual time=0.008..0.115 rows=468 loops=3)
                                                   ->  Hash  (cost=11.30..11.30 rows=130 width=568) (actual time=0.004..0.004 rows=0 loops=3)
                                                         Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                                         ->  Seq Scan on "CreateShards" "createShard"  (cost=0.00..11.30 rows=130 width=568) (actual time=0.004..0.004 rows=0 loops=3)
                                             ->  Hash  (cost=11.30..11.30 rows=130 width=568) (actual time=0.004..0.004 rows=0 loops=3)
                                                   Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                                   ->  Seq Scan on "SetShardOwners" "setShardOwners"  (cost=0.00..11.30 rows=130 width=568) (actual time=0.004..0.004 rows=0 loops=3)
                                       ->  Hash  (cost=11.30..11.30 rows=130 width=568) (actual time=0.003..0.003 rows=0 loops=3)
                                             Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                             ->  Seq Scan on "SetShardUsers" "setShardUsers"  (cost=0.00..11.30 rows=130 width=568) (actual time=0.002..0.003 rows=0 loops=3)
                                 ->  Hash  (cost=10.30..10.30 rows=30 width=2080) (actual time=0.003..0.003 rows=0 loops=3)
                                       Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                       ->  Seq Scan on "Stores" store  (cost=0.00..10.30 rows=30 width=2080) (actual time=0.003..0.003 rows=0 loops=3)
                           ->  Hash  (cost=10.50..10.50 rows=50 width=1564) (actual time=0.003..0.003 rows=0 loops=3)
                                 Buckets: 1024  Batches: 1  Memory Usage: 8kB
                                 ->  Seq Scan on "Removes" remove  (cost=0.00..10.50 rows=50 width=1564) (actual time=0.003..0.003 rows=0 loops=3)
                     ->  Hash  (cost=10.70..10.70 rows=70 width=1052) (actual time=0.009..0.009 rows=7 loops=3)
                           Buckets: 1024  Batches: 1  Memory Usage: 10kB
                           ->  Seq Scan on "Customs" custom  (cost=0.00..10.70 rows=70 width=1052) (actual time=0.005..0.006 rows=7 loops=3)
 Planning time: 29.504 ms
 Execution time: 397.914 ms
(86 rows)

For Pay

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=677855.16..677878.49 rows=200 width=22024) (actual time=639.206..645.607 rows=200 loops=1)
   ->  Gather Merge  (cost=677855.16..685297.14 rows=63784 width=22024) (actual time=639.205..645.582 rows=200 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         ->  Sort  (cost=676855.13..676934.86 rows=31892 width=22024) (actual time=562.693..562.728 rows=151 loops=3)
               Sort Key: "Transaction"."blockNumber" DESC, "Transaction"."transactionIndex" DESC
               Sort Method: external merge  Disk: 10544kB
               ->  Merge Left Join  (cost=20282.08..73624.47 rows=31892 width=22024) (actual time=144.169..522.829 rows=25950 loops=3)
                     Merge Cond: (("Transaction".hash)::text = (custom."transactionHash")::text)
                     ->  Merge Left Join  (cost=20269.23..73531.39 rows=31892 width=20972) (actual time=144.158..506.040 rows=25950 loops=3)
                           Merge Cond: (("Transaction".hash)::text = (remove."transactionHash")::text)
                           ->  Merge Left Join  (cost=20257.32..73439.39 rows=31892 width=19408) (actual time=144.151..493.550 rows=25950 loops=3)
                                 Merge Cond: (("Transaction".hash)::text = (store."transactionHash")::text)
                                 ->  Merge Left Join  (cost=20246.28..73348.42 rows=31892 width=17328) (actual time=144.143..481.081 rows=25950 loops=3)
                                       Merge Cond: (("Transaction".hash)::text = ("setShardUsers"."transactionHash")::text)
                                       ->  Merge Left Join  (cost=20230.42..73251.89 rows=31892 width=16760) (actual time=144.136..469.202 rows=25950 loops=3)
                                             Merge Cond: (("Transaction".hash)::text = ("setShardOwners"."transactionHash")::text)
                                             ->  Merge Left Join  (cost=20214.56..73155.37 rows=31892 width=16192) (actual time=144.130..457.401 rows=25950 loops=3)
                                                   Merge Cond: (("Transaction".hash)::text = ("createShard"."transactionHash")::text)
                                                   ->  Merge Left Join  (cost=20198.69..73058.84 rows=31892 width=15624) (actual time=144.120..445.846 rows=25950 loops=3)
                                                         Merge Cond: (("Transaction".hash)::text = ("setRegularKey"."transactionHash")::text)
                                                         ->  Merge Left Join  (cost=20137.36..72914.57 rows=31892 width=15411) (actual time=143.613..429.940 rows=25950 loops=3)
                                                               Merge Cond: (("Transaction".hash)::text = (pay."transactionHash")::text)
                                                               ->  Merge Left Join  (cost=20136.94..59993.88 rows=31892 width=15281) (actual time=143.598..343.518 rows=25950 loops=3)
                                                                     Merge Cond: (("Transaction".hash)::text = ("unwrapCCC"."transactionHash")::text)
                                                                     ->  Merge Left Join  (cost=20136.53..50396.48 rows=31892 width=14231) (actual time=143.566..313.799 rows=25950 loops=3)
                                                                           Merge Cond: (("Transaction".hash)::text = ("wrapCCC"."transactionHash")::text)
                                                                           ->  Merge Left Join  (cost=18439.58..48513.90 rows=31892 width=14005) (actual time=96.866..245.964 rows=25950 loops=3)
                                                                                 Merge Cond: (("Transaction".hash)::text = ("increaseAssetSupply"."transactionHash")::text)
                                                                                 ->  Merge Left Join  (cost=18428.55..48422.92 rows=31892 width=11317) (actual time=96.856..236.106 rows=25950 loops=3)
                                                                                       Merge Cond: (("Transaction".hash)::text = ("changeAssetScheme"."transactionHash")::text)
                                                                                       ->  Merge Left Join  (cost=18417.91..48332.42 rows=31892 width=8617) (actual time=96.849..227.341 rows=25950 loops=3)
                                                                                             Merge Cond: (("Transaction".hash)::text = ("decomposeAsset"."transactionHash")::text)
                                                                                             ->  Merge Left Join  (cost=18405.54..48239.89 rows=31892 width=7473) (actual time=96.839..219.271 rows=25950 loops=3)
                                                                                                   Merge Cond: (("Transaction".hash)::text = ("composeAsset"."transactionHash")::text)
                                                                                                   ->  Nested Loop Left Join  (cost=18395.28..48149.82 rows=31892 width=3145) (actual time=96.820..211.483 rows=25950 loops=3)
                                                                                                         ->  Merge Left Join  (cost=18394.86..18569.70 rows=31892 width=1472) (actual time=96.787..123.483 rows=25950 loops=3)
                                                                                                               Merge Cond: (("Transaction".hash)::text = ("mintAsset"."transactionHash")::text)
                                                                                                               ->  Sort  (cost=18097.92..18177.65 rows=31892 width=458) (actual time=92.585..105.922 rows=25950 loops=3)
                                                                                                                     Sort Key: "Transaction".hash
                                                                                                                     Sort Method: external merge  Disk: 7560kB
                                                                                                                     ->  Parallel Seq Scan on "Transactions" "Transaction"  (cost=0.00..9062.26 rows=31892 width=458) (actual time=0.019..17.486 rows=25950 loops=3)
                                                                                                                           Filter: ((NOT "isPending") AND ((type)::text = 'pay'::text))
                                                                                                                           Rows Removed by Filter: 23953
                                                                                                               ->  Sort  (cost=296.94..302.33 rows=2156 width=1014) (actual time=4.195..4.686 rows=2155 loops=3)
                                                                                                                     Sort Key: "mintAsset"."transactionHash"
                                                                                                                     Sort Method: quicksort  Memory: 1262kB
                                                                                                                     ->  Seq Scan on "MintAssets" "mintAsset"  (cost=0.00..177.56 rows=2156 width=1014) (actual time=0.026..0.915 rows=2155 loops=3)
                                                                                                         ->  Index Scan using "TransferAssets_pkey" on "TransferAssets" "transferAsset"  (cost=0.41..0.93 rows=1 width=1673) (actual time=0.003..0.003 rows=0 loops=77849)
                                                                                                               Index Cond: (("Transaction".hash)::text = ("transactionHash")::text)
                                                                                                   ->  Sort  (cost=10.27..10.29 rows=10 width=4328) (actual time=0.017..0.017 rows=0 loops=3)
                                                                                                         Sort Key: "composeAsset"."transactionHash"
                                                                                                         Sort Method: quicksort  Memory: 25kB
                                                                                                         ->  Seq Scan on "ComposeAssets" "composeAsset"  (cost=0.00..10.10 rows=10 width=4328) (actual time=0.007..0.007 rows=0 loops=3)
                                                                                             ->  Sort  (cost=12.37..12.52 rows=60 width=1144) (actual time=0.007..0.007 rows=0 loops=3)
                                                                                                   Sort Key: "decomposeAsset"."transactionHash"
                                                                                                   Sort Method: quicksort  Memory: 25kB
                                                                                                   ->  Seq Scan on "DecomposeAssets" "decomposeAsset"  (cost=0.00..10.60 rows=60 width=1144) (actual time=0.004..0.004 rows=0 loops=3)
                                                                                       ->  Sort  (cost=10.63..10.68 rows=20 width=2700) (actual time=0.006..0.006 rows=0 loops=3)
                                                                                             Sort Key: "changeAssetScheme"."transactionHash"
                                                                                             Sort Method: quicksort  Memory: 25kB
                                                                                             ->  Seq Scan on "ChangeAssetSchemes" "changeAssetScheme"  (cost=0.00..10.20 rows=20 width=2700) (actual time=0.003..0.003 rows=0 loops=3)
                                                                                 ->  Sort  (cost=11.04..11.11 rows=30 width=2688) (actual time=0.008..0.008 rows=0 loops=3)
                                                                                       Sort Key: "increaseAssetSupply"."transactionHash"
                                                                                       Sort Method: quicksort  Memory: 25kB
                                                                                       ->  Seq Scan on "IncreaseAssetSupplies" "increaseAssetSupply"  (cost=0.00..10.30 rows=30 width=2688) (actual time=0.003..0.003 rows=0 loops=3)
                                                                           ->  Sort  (cost=1696.95..1734.06 rows=14844 width=226) (actual time=46.695..49.354 rows=14870 loops=3)
                                                                                 Sort Key: "wrapCCC"."transactionHash"
                                                                                 Sort Method: external merge  Disk: 3528kB
                                                                                 ->  Seq Scan on "WrapCCCs" "wrapCCC"  (cost=0.00..668.44 rows=14844 width=226) (actual time=0.007..2.391 rows=14870 loops=3)
                                                                     ->  Index Scan using "UnwrapCCCs_pkey" on "UnwrapCCCs" "unwrapCCC"  (cost=0.41..9451.27 rows=14328 width=1050) (actual time=0.026..11.500 rows=14327 loops=3)
                                                               ->  Index Scan using "Pays_pkey" on "Pays" pay  (cost=0.42..12480.18 rows=77851 width=130) (actual time=0.010..52.259 rows=77847 loops=3)
                                                         ->  Sort  (cost=61.33..62.46 rows=450 width=213) (actual time=0.504..0.635 rows=468 loops=3)
                                                               Sort Key: "setRegularKey"."transactionHash"
                                                               Sort Method: quicksort  Memory: 149kB
                                                               ->  Seq Scan on "SetRegularKeys" "setRegularKey"  (cost=0.00..41.50 rows=450 width=213) (actual time=0.011..0.121 rows=468 loops=3)
                                                   ->  Sort  (cost=15.86..16.19 rows=130 width=568) (actual time=0.008..0.008 rows=0 loops=3)
                                                         Sort Key: "createShard"."transactionHash"
                                                         Sort Method: quicksort  Memory: 25kB
                                                         ->  Seq Scan on "CreateShards" "createShard"  (cost=0.00..11.30 rows=130 width=568) (actual time=0.005..0.005 rows=0 loops=3)
                                             ->  Sort  (cost=15.86..16.19 rows=130 width=568) (actual time=0.004..0.004 rows=0 loops=3)
                                                   Sort Key: "setShardOwners"."transactionHash"
                                                   Sort Method: quicksort  Memory: 25kB
                                                   ->  Seq Scan on "SetShardOwners" "setShardOwners"  (cost=0.00..11.30 rows=130 width=568) (actual time=0.003..0.003 rows=0 loops=3)
                                       ->  Sort  (cost=15.86..16.19 rows=130 width=568) (actual time=0.004..0.004 rows=0 loops=3)
                                             Sort Key: "setShardUsers"."transactionHash"
                                             Sort Method: quicksort  Memory: 25kB
                                             ->  Seq Scan on "SetShardUsers" "setShardUsers"  (cost=0.00..11.30 rows=130 width=568) (actual time=0.003..0.003 rows=0 loops=3)
                                 ->  Sort  (cost=11.04..11.11 rows=30 width=2080) (actual time=0.005..0.005 rows=0 loops=3)
                                       Sort Key: store."transactionHash"
                                       Sort Method: quicksort  Memory: 25kB
                                       ->  Seq Scan on "Stores" store  (cost=0.00..10.30 rows=30 width=2080) (actual time=0.004..0.004 rows=0 loops=3)
                           ->  Sort  (cost=11.91..12.04 rows=50 width=1564) (actual time=0.004..0.004 rows=0 loops=3)
                                 Sort Key: remove."transactionHash"
                                 Sort Method: quicksort  Memory: 25kB
                                 ->  Seq Scan on "Removes" remove  (cost=0.00..10.50 rows=50 width=1564) (actual time=0.003..0.003 rows=0 loops=3)
                     ->  Sort  (cost=12.85..13.02 rows=70 width=1052) (actual time=0.009..0.011 rows=7 loops=3)
                           Sort Key: custom."transactionHash"
                           Sort Method: quicksort  Memory: 26kB
                           ->  Seq Scan on "Customs" custom  (cost=0.00..10.70 rows=70 width=1052) (actual time=0.005..0.005 rows=7 loops=3)
 Planning time: 25.181 ms
 Execution time: 648.608 ms
(102 rows)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions