PgHero

Queries

Total Time Average Time Calls
17,837 min 54% 2,265 ms 472,548 hasura
SELECT  "_subs"."result_id" , "_fld_resp"."root" AS "result" FROM UNNEST(($1)::uuid[], ($2)::json[]) AS "_subs"("result_id", "result_vars") LEFT OUTER JOIN LATERAL (SELECT  json_build_object($3, "node_block"."root" ) AS "root" FROM  (SELECT  coalesce(json_agg("root" ORDER BY "root.or.block.pg.height" DESC NULLS FIRST), $4 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.block"."block" AS "block", $5 AS "__typename"       ) AS "_e"      ) ) AS "root", "_root.or.block"."root.or.block.pg.height" AS "root.or.block.pg.height" FROM  (SELECT  *  FROM "public"."node_block"  WHERE (EXISTS  (SELECT  $6  FROM "public"."node" AS "__be_0_node" WHERE (((("__be_0_node"."internal_id") = ("public"."node_block"."node_internal_id")) AND ($7)) AND (($8) AND ((((("__be_0_node"."name") ~ ((("_subs"."result_vars"#>>ARRAY[$9, $10]))::text)) AND ($11)) AND ($12)) AND ($13))))     ))     ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.or.block.base"."height")::text AS "height", $14 AS "__typename"       ) AS "_e"      ) ) AS "block", "_root.or.block.base"."height" AS "root.or.block.pg.height" FROM  (SELECT  *  FROM "public"."block"  WHERE (("_root.base"."block_internal_id") = ("internal_id"))    LIMIT $15 ) AS "_root.or.block.base"      ) AS "_root.or.block" ON ($16)    ORDER BY "root.or.block.pg.height" DESC NULLS FIRST LIMIT $17 ) AS "_root"      ) AS "node_block"      ) AS "_fld_resp" ON ($18)
3,130 min 9% 12,933 ms 14,520 chaingraph
WITH accepted_transactions AS (
	SELECT node_internal_id, transaction_internal_id, accepted_at FROM block_transaction INNER JOIN new_table ON block_transaction.block_internal_id = new_table.block_internal_id
),
newly_spent AS (
	SELECT accepted_transactions.node_internal_id, accepted_transactions.transaction_internal_id, accepted_transactions.accepted_at, input.outpoint_index
		FROM input INNER JOIN accepted_transactions ON input.transaction_internal_id = accepted_transactions.transaction_internal_id
),
accepted_and_replaced_transactions AS (
    SELECT newly_spent.node_internal_id, input.transaction_internal_id, CASE WHEN input.transaction_internal_id != newly_spent.transaction_internal_id THEN newly_spent.accepted_at ELSE $1 END AS replaced_at
        FROM input INNER JOIN newly_spent ON input.transaction_internal_id = newly_spent.transaction_internal_id AND input.outpoint_index = newly_spent.outpoint_index
        WHERE input.outpoint_transaction_hash != $2::bytea
--        GROUP BY newly_spent.node_internal_id, input.transaction_internal_id, replaced -- doesn't improve performance
),
deleted_node_transactions AS (
    DELETE FROM node_transaction
        USING accepted_and_replaced_transactions
        WHERE node_transaction.node_internal_id = accepted_and_replaced_transactions.node_internal_id
            AND node_transaction.transaction_internal_id = accepted_and_replaced_transactions.transaction_internal_id
        RETURNING node_transaction.node_internal_id, node_transaction.transaction_internal_id, validated_at, accepted_and_replaced_transactions.replaced_at
)
INSERT INTO node_transaction_history (node_internal_id, transaction_internal_id, validated_at, replaced_at)
	SELECT node_internal_id, transaction_internal_id, validated_at, replaced_at FROM deleted_node_transactions
2,660 min 8% 354 ms 450,806 hasura
SELECT  coalesce(json_agg("root" ), $3 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("public"."transaction"."hash") = (($2)::bytea))    LIMIT $4 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $5 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $6 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead"."authhead" AS "authhead", "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead.base"."hash" AS "hash", "_root.ar.root.authchains.or.authhead.cf.identity_output"."identity_output" AS "identity_output"       ) AS "_e"      ) ) AS "authhead" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.authchains.base"."authhead_transaction_hash") = ("hash"))    LIMIT $7 ) AS "_root.ar.root.authchains.or.authhead.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("identity_output" ), $8 ) AS "identity_output" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.ar.root.authchains.or.authhead.cf.identity_output.base"."fungible_token_amount")::text AS "fungible_token_amount"       ) AS "_e"      ) ) AS "identity_output" FROM  (SELECT  *  FROM "public"."transaction_identity_output"("_root.ar.root.authchains.or.authhead.base") AS "_transaction_identity_output" WHERE ($9)    LIMIT $10 ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output.base"      ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output"      ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output" ON ($11)      ) AS "_root.ar.root.authchains.or.authhead" ON ($12)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($13)      ) AS "_root"
1,612 min 5% 1,502 ms 64,378 hasura
SELECT  coalesce(json_agg("root" ), $7 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE ((EXISTS  (SELECT  $8  FROM "public"."block_transaction" AS "__be_0_block_transaction" WHERE (((("__be_0_block_transaction"."transaction_internal_id") = ("public"."transaction"."internal_id")) AND ($9)) AND (($10) AND (((EXISTS  (SELECT  $11  FROM "public"."block" AS "__be_1_block" WHERE (((("__be_1_block"."internal_id") = ("__be_0_block_transaction"."block_internal_id")) AND ($12)) AND (($13) AND (((EXISTS  (SELECT  $14  FROM "public"."node_block" AS "__be_2_node_block" WHERE (((("__be_2_node_block"."block_internal_id") = ("__be_1_block"."internal_id")) AND ($15)) AND (($16) AND (((EXISTS  (SELECT  $17  FROM "public"."node" AS "__be_3_node" WHERE (((("__be_3_node"."internal_id") = ("__be_2_node_block"."node_internal_id")) AND ($18)) AND (($19) AND ((((("__be_3_node"."name") ILIKE (($5)::text)) AND ($20)) AND ($21)) AND ($22))))     )) AND ($23)) AND ($24))))     )) AND ($25)) AND ($26))))     )) AND ($27)) AND ($28))))     )) AND (("public"."transaction"."hash") = (($6)::bytea)))    LIMIT $29 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $30 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $31 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length", "_root.ar.root.authchains.ar.authchains.migrations"."migrations" AS "migrations"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."migrations" ), $32 )  FROM  (SELECT  "_unnest_table"."migrations" AS "migrations" FROM UNNEST(array_agg("migrations" )) AS "_unnest_table"("migrations")     LIMIT $33 ) AS "_sub_query"      ) AS "migrations" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "migrations" FROM  (SELECT  *  FROM "public"."authchain_migrations_view"  WHERE ((("_root.ar.root.authchains.base"."transaction_internal_id") = ("authbase_internal_id")) AND (EXISTS  (SELECT  $34  FROM "public"."authchain_migration_transaction"("public"."authchain_migrations_view".*) AS "__be_0_authchain_migration_transaction" WHERE ((EXISTS  (SELECT  $35  FROM "public"."output" AS "__be_1_output" WHERE (((("__be_1_output"."transaction_hash") = ("__be_0_authchain_migration_transaction"."hash")) AND ($36)) AND (($37) AND ((((("public"."output_locking_bytecode_pattern"("__be_1_output".*) ) LIKE (($4)::text)) AND ($38)) AND ($39)) AND ($40))))     )) AND ($41))     )))     ) AS "_root.ar.root.authchains.ar.authchains.migrations.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("transaction" ), $42 ) AS "transaction" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash" AS "hash", "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."authchain_migration_transaction"("_root.ar.root.authchains.ar.authchains.migrations.base") AS "_authchain_migration_transaction" WHERE ($43)    LIMIT $44 ) AS "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $45 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $46 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash") = ("transaction_hash")) AND (("public"."output_locking_bytecode_pattern"("public"."output".*) ) LIKE (($3)::text)))     ) AS "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs" ON ($47) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $48 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $49 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"."outpoint_index")::text AS "outpoint_index"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."internal_id") = ("transaction_internal_id")) AND (("public"."input"."outpoint_index") = (($2)::bigint)))     ) AS "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs" ON ($50)      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction" ON ($51)      ) AS "_root.ar.root.authchains.ar.authchains.migrations"      ) AS "_root.ar.root.authchains.ar.authchains.migrations" ON ($52)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($53)      ) AS "_root"
852 min 3% 675 ms 75,705 hasura
SELECT  coalesce(json_agg("root" ORDER BY "root.or.transaction.pg.internal_id" DESC NULLS FIRST), $5 ) AS "root" FROM  (SELECT  "_root.or.transaction"."root.or.transaction.pg.internal_id" AS "root.or.transaction.pg.internal_id", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."locking_bytecode" AS "locking_bytecode", ("_root.base"."output_index")::text AS "output_index", "_root.base"."transaction_hash" AS "transaction_hash", "_root.or.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."search_output_prefix"(($4)::text) AS "_search_output_prefix" WHERE ($6)     ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  "_root.or.transaction.base"."internal_id" AS "root.or.transaction.pg.internal_id", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.base"."transaction_hash") = ("hash"))    LIMIT $7 ) AS "_root.or.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $8 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $9 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.or.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "_root.or.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode", ("_root.or.transaction.ar.transaction.outputs.base"."value_satoshis")::text AS "value_satoshis", "_root.or.transaction.ar.transaction.outputs.base"."token_category" AS "token_category", ("_root.or.transaction.ar.transaction.outputs.base"."fungible_token_amount")::text AS "fungible_token_amount", "_root.or.transaction.ar.transaction.outputs.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "_root.or.transaction.ar.transaction.outputs.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "_root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by"."spent_by" AS "spent_by"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("_root.or.transaction.base"."hash") = ("transaction_hash")) AND ((EXISTS  (SELECT  $10  FROM "public"."input" AS "__be_0_input" WHERE (((("__be_0_input"."outpoint_transaction_hash") = ("public"."output"."transaction_hash")) AND ((("__be_0_input"."outpoint_index") = ("public"."output"."output_index")) AND ($11))) AND (($12) AND (($13) AND ($14))))     )) AND (("public"."output"."output_index") = (($3)::bigint))))     ) AS "_root.or.transaction.ar.transaction.outputs.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."spent_by" ), $15 )  FROM  (SELECT  "_unnest_table"."spent_by" AS "spent_by" FROM UNNEST(array_agg("spent_by" )) AS "_unnest_table"("spent_by")     LIMIT $16 ) AS "_sub_query"      ) AS "spent_by" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_3af85ef6759567edc35d019973cef70b__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "spent_by" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("_root.or.transaction.ar.transaction.outputs.base"."transaction_hash") = ("outpoint_transaction_hash")) AND (("_root.or.transaction.ar.transaction.outputs.base"."output_index") = ("outpoint_index")))     ) AS "md5_c69a32c7249ae273493b855f08ee549c__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_181392f418616e550665e586cb3dbc16__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions"."block_inclusions" AS "block_inclusions", ("md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base"."internal_id")::text AS "internal_id", "md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base"."hash" AS "hash", "md5_1b3260a66a35d300a3d7ac7e3c3347a5__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("md5_c69a32c7249ae273493b855f08ee549c__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.base"."transaction_internal_id") = ("internal_id"))    LIMIT $17 ) AS "md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $18 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $19 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_860acf75867510eadfd27a325f171812__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base"."hash") = ("transaction_hash")) AND (("public"."output"."output_index") = ANY(($2)::bigint[])))     ) AS "md5_860acf75867510eadfd27a325f171812__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.outputs.base"      ) AS "md5_1b3260a66a35d300a3d7ac7e3c3347a5__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.outputs"      ) AS "md5_1b3260a66a35d300a3d7ac7e3c3347a5__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.outputs" ON ($20) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."block_inclusions" ), $21 )  FROM  (SELECT  "_unnest_table"."block_inclusions" AS "block_inclusions" FROM UNNEST(array_agg("block_inclusions" )) AS "_unnest_table"("block_inclusions")     LIMIT $22 ) AS "_sub_query"      ) AS "block_inclusions" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_5929a96f9409d321c13410a3ca4f8c1d__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions.or.block"."block" AS "block"       ) AS "_e"      ) ) AS "block_inclusions" FROM  (SELECT  *  FROM "public"."block_transaction"  WHERE (("md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base"."internal_id") = ("transaction_internal_id"))     ) AS "md5_635f8bcc7d4d5d7954ca7598199b70ed__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_7eded9211c0c5b18502ad01279455113__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions.or.block.base"."timestamp")::text AS "timestamp"       ) AS "_e"      ) ) AS "block" FROM  (SELECT  *  FROM "public"."block"  WHERE (("md5_635f8bcc7d4d5d7954ca7598199b70ed__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions.base"."block_internal_id") = ("internal_id"))    LIMIT $23 ) AS "md5_7eded9211c0c5b18502ad01279455113__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions.or.block.base"      ) AS "md5_5929a96f9409d321c13410a3ca4f8c1d__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions.or.block" ON ($24)      ) AS "md5_181392f418616e550665e586cb3dbc16__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions"      ) AS "md5_181392f418616e550665e586cb3dbc16__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.ar.transaction.block_inclusions" ON ($25)      ) AS "md5_3af85ef6759567edc35d019973cef70b__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction" ON ($26)      ) AS "_root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by"      ) AS "_root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by" ON ($27)      ) AS "_root.or.transaction.ar.transaction.outputs"      ) AS "_root.or.transaction.ar.transaction.outputs" ON ($28)      ) AS "_root.or.transaction" ON ($29)    ORDER BY "root.or.transaction.pg.internal_id" DESC NULLS FIRST LIMIT $30 ) AS "_root"
633 min 2% 222 ms 170,968 hasura
SELECT  "_subs"."result_id" , "_fld_resp"."root" AS "result" FROM UNNEST(($1)::uuid[], ($2)::json[]) AS "_subs"("result_id", "result_vars") LEFT OUTER JOIN LATERAL (SELECT  json_build_object($3, "block"."root" ) AS "root" FROM  (SELECT  coalesce(json_agg("root" ORDER BY "root.pg.height" DESC NULLS FIRST), $4 ) AS "root" FROM  (SELECT  "_root.base"."height" AS "root.pg.height", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", ("_root.base"."height")::text AS "height", ("public"."block_transaction_count"("_root.base") )::text AS "transaction_count", ("public"."block_input_count"("_root.base") )::text AS "input_count", ("public"."block_output_count"("_root.base") )::text AS "output_count", ("public"."block_output_value_satoshis"("_root.base") )::text AS "output_value_satoshis", ("_root.base"."size_bytes")::text AS "size_bytes", ("public"."block_generated_value_satoshis"("_root.base") )::text AS "generated_value_satoshis", ("_root.base"."timestamp")::text AS "timestamp", $5 AS "__typename"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."block"  WHERE (EXISTS  (SELECT  $6  FROM "public"."node_block" AS "__be_0_node_block" WHERE (((("__be_0_node_block"."block_internal_id") = ("public"."block"."internal_id")) AND ($7)) AND (($8) AND (((EXISTS  (SELECT  $9  FROM "public"."node" AS "__be_1_node" WHERE (((("__be_1_node"."internal_id") = ("__be_0_node_block"."node_internal_id")) AND ($10)) AND (($11) AND ((((("__be_1_node"."name") ~ ((("_subs"."result_vars"#>>ARRAY[$12, $13]))::text)) AND ($14)) AND ($15)) AND ($16))))     )) AND ($17)) AND ($18))))     ))   ORDER BY "height" DESC NULLS FIRST LIMIT $19 OFFSET $20) AS "_root.base"    ORDER BY "root.pg.height" DESC NULLS FIRST  ) AS "_root"      ) AS "block"      ) AS "_fld_resp" ON ($21)
539 min 2% 427 ms 75,854 hasura
SELECT  coalesce(json_agg("root" ORDER BY "root.or.transaction.pg.internal_id" DESC NULLS FIRST), $4 ) AS "root" FROM  (SELECT  "_root.or.transaction"."root.or.transaction.pg.internal_id" AS "root.or.transaction.pg.internal_id", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."locking_bytecode" AS "locking_bytecode", ("_root.base"."output_index")::text AS "output_index", "_root.base"."transaction_hash" AS "transaction_hash", "_root.or.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."search_output_prefix"(($3)::text) AS "_search_output_prefix" WHERE ($5)     ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  "_root.or.transaction.base"."internal_id" AS "root.or.transaction.pg.internal_id", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.base"."transaction_hash") = ("hash"))    LIMIT $6 ) AS "_root.or.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $7 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $8 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.or.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "_root.or.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode", ("_root.or.transaction.ar.transaction.outputs.base"."value_satoshis")::text AS "value_satoshis", "_root.or.transaction.ar.transaction.outputs.base"."token_category" AS "token_category", ("_root.or.transaction.ar.transaction.outputs.base"."fungible_token_amount")::text AS "fungible_token_amount", "_root.or.transaction.ar.transaction.outputs.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "_root.or.transaction.ar.transaction.outputs.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "_root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by"."spent_by" AS "spent_by"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("_root.or.transaction.base"."hash") = ("transaction_hash")) AND ((("public"."output"."output_index") = (($2)::bigint)) AND (NOT ((EXISTS  (SELECT  $9  FROM "public"."input" AS "__be_0_input" WHERE (((("__be_0_input"."outpoint_transaction_hash") = ("public"."output"."transaction_hash")) AND ((("__be_0_input"."outpoint_index") = ("public"."output"."output_index")) AND ($10))) AND (($11) AND (($12) AND ($13))))     )) AND ($14)))))     ) AS "_root.or.transaction.ar.transaction.outputs.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."spent_by" ), $15 )  FROM  (SELECT  "_unnest_table"."spent_by" AS "spent_by" FROM UNNEST(array_agg("spent_by" )) AS "_unnest_table"("spent_by")     LIMIT $16 ) AS "_sub_query"      ) AS "spent_by" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_3af85ef6759567edc35d019973cef70b__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "spent_by" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("_root.or.transaction.ar.transaction.outputs.base"."transaction_hash") = ("outpoint_transaction_hash")) AND (("_root.or.transaction.ar.transaction.outputs.base"."output_index") = ("outpoint_index")))     ) AS "md5_c69a32c7249ae273493b855f08ee549c__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base"."hash" AS "hash"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("md5_c69a32c7249ae273493b855f08ee549c__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.base"."transaction_internal_id") = ("internal_id"))    LIMIT $17 ) AS "md5_198b85e60ca014a5b676ba4d2eb441b1__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction.base"      ) AS "md5_3af85ef6759567edc35d019973cef70b__root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by.or.transaction" ON ($18)      ) AS "_root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by"      ) AS "_root.or.transaction.ar.transaction.outputs.ar.outputs.spent_by" ON ($19)      ) AS "_root.or.transaction.ar.transaction.outputs"      ) AS "_root.or.transaction.ar.transaction.outputs" ON ($20)      ) AS "_root.or.transaction" ON ($21)    ORDER BY "root.or.transaction.pg.internal_id" DESC NULLS FIRST LIMIT $22 ) AS "_root"
474 min 1% 796 ms 35,751 hasura
SELECT  coalesce(json_agg("root" ), $6 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("public"."transaction"."hash") = ANY(($5)::bytea[]))    LIMIT $7 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $8 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $9 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length", "_root.ar.root.authchains.ar.authchains.migrations"."migrations" AS "migrations"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."migrations" ORDER BY "ob_col_1" DESC NULLS FIRST), $10 )  FROM  (SELECT  "_unnest_table"."migrations" AS "migrations", "_unnest_table"."ob_col_1" AS "ob_col_1" FROM UNNEST(array_agg("migrations" ), array_agg("md5_3e9df6841b24f1f40a5034f7fc1c5d8d_root.ar.root.authchains.ar.authchains.migrations.pg.migration_index" )) AS "_unnest_table"("migrations", "ob_col_1")    ORDER BY "ob_col_1" DESC NULLS FIRST LIMIT $11 ) AS "_sub_query"      ) AS "migrations" FROM  (SELECT  "_root.ar.root.authchains.ar.authchains.migrations.base"."migration_index" AS "md5_3e9df6841b24f1f40a5034f7fc1c5d8d_root.ar.root.authchains.ar.authchains.migrations.pg.migration_index", row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "migrations" FROM  (SELECT  *  FROM "public"."authchain_migrations_view"  WHERE ((("_root.ar.root.authchains.base"."transaction_internal_id") = ("authbase_internal_id")) AND (EXISTS  (SELECT  $12  FROM "public"."authchain_migration_transaction"("public"."authchain_migrations_view".*) AS "__be_0_authchain_migration_transaction" WHERE ((EXISTS  (SELECT  $13  FROM "public"."output" AS "__be_1_output" WHERE (((("__be_1_output"."transaction_hash") = ("__be_0_authchain_migration_transaction"."hash")) AND ($14)) AND (($15) AND ((((("public"."output_locking_bytecode_pattern"("__be_1_output".*) ) LIKE (($4)::text)) AND ($16)) AND ($17)) AND ($18))))     )) AND ($19))     )))   ORDER BY "migration_index" DESC NULLS FIRST LIMIT $20 ) AS "_root.ar.root.authchains.ar.authchains.migrations.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("transaction" ), $21 ) AS "transaction" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash" AS "hash", "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."authchain_migration_transaction"("_root.ar.root.authchains.ar.authchains.migrations.base") AS "_authchain_migration_transaction" WHERE ($22)    LIMIT $23 ) AS "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $24 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $25 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash") = ("transaction_hash")) AND (("public"."output_locking_bytecode_pattern"("public"."output".*) ) LIKE (($3)::text)))     ) AS "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs" ON ($26) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $27 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $28 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"."outpoint_index")::text AS "outpoint_index"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."internal_id") = ("transaction_internal_id")) AND (("public"."input"."outpoint_index") = (($2)::bigint)))     ) AS "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs" ON ($29)      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction" ON ($30)    ORDER BY "md5_3e9df6841b24f1f40a5034f7fc1c5d8d_root.ar.root.authchains.ar.authchains.migrations.pg.migration_index" DESC NULLS FIRST  ) AS "_root.ar.root.authchains.ar.authchains.migrations"      ) AS "_root.ar.root.authchains.ar.authchains.migrations" ON ($31)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($32)      ) AS "_root"
437 min 1% 22 ms 1,196,981 hasura
SELECT (block_output_value_satoshis(block) - block_input_value_satoshis(block))::bigint FROM block WHERE internal_id = block_row.internal_id
414 min 1% 606,427 ms 41 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint),($113::bytea, $114::bigint),($115::bytea, $116::bigint),($117::bytea, $118::bigint),($119::bytea, $120::bigint),($121::bytea, $122::bigint),($123::bytea, $124::bigint),($125::bytea, $126::bigint),($127::bytea, $128::bigint),($129::bytea, $130::bigint),($131::bytea, $132::bigint),($133::bytea, $134::bigint),($135::bytea, $136::bigint),($137::bytea, $138::bigint),($139::bytea, $140::bigint),($141::bytea, $142::bigint),($143::bytea, $144::bigint),($145::bytea, $146::bigint),($147::bytea, $148::bigint),($149::bytea, $150::bigint),($151::bytea, $152::bigint),($153::bytea, $154::bigint),($155::bytea, $156::bigint),($157::bytea, $158::bigint),($159::bytea, $160::bigint),($161::bytea, $162::bigint),($163::bytea, $164::bigint),($165::bytea, $166::bigint),($167::bytea, $168::bigint),($169::bytea, $170::bigint),($171::bytea, $172::bigint),($173::bytea, $174::bigint),($175::bytea, $176::bigint),($177::bytea, $178::bigint),($179::bytea, $180::bigint),($181::bytea, $182::bigint),($183::bytea, $184::bigint),($185::bytea, $186::bigint),($187::bytea, $188::bigint),($189::bytea, $190::bigint),($191::bytea, $192::bigint),($193::bytea, $194::bigint),($195::bytea, $196::bigint),($197::bytea, $198::bigint),($199::bytea, $200::bigint),($201::bytea, $202::bigint),($203::bytea, $204::bigint),($205::bytea, $206::bigint),($207::bytea, $208::bigint),($209::bytea, $210::bigint),($211::bytea, $212::bigint),($213::bytea, $214::bigint),($215::bytea, $216::bigint),($217::bytea, $218::bigint),($219::bytea, $220::bigint),($221::bytea, $222::bigint),($223::bytea, $224::bigint),($225::bytea, $226::bigint),($227::bytea, $228::bigint),($229::bytea, $230::bigint),($231::bytea, $232::bigint),($233::bytea, $234::bigint),($235::bytea, $236::bigint),($237::bytea, $238::bigint),($239::bytea, $240::bigint),($241::bytea, $242::bigint),($243::bytea, $244::bigint),($245::bytea, $246::bigint),($247::bytea, $248::bigint),($249::bytea, $250::bigint),($251::bytea, $252::bigint),($253::bytea, $254::bigint),($255::bytea, $256::bigint),($257::bytea, $258::bigint),($259::bytea, $260::bigint),($261::bytea, $262::bigint),($263::bytea, $264::bigint),($265::bytea, $266::bigint),($267::bytea, $268::bigint),($269::bytea, $270::bigint),($271::bytea, $272::bigint),($273::bytea, $274::bigint),($275::bytea, $276::bigint),($277::bytea, $278::bigint),($279::bytea, $280::bigint),($281::bytea, $282::bigint),($283::bytea, $284::bigint),($285::bytea, $286::bigint),($287::bytea, $288::bigint),($289::bytea, $290::bigint),($291::bytea, $292::bigint),($293::bytea, $294::bigint),($295::bytea, $296::bigint),($297::bytea, $298::bigint),($299::bytea, $300::bigint),($301::bytea, $302::bigint),($303::bytea, $304::bigint),($305::bytea, $306::bigint),($307::bytea, $308::bigint),($309::bytea, $310::bigint),($311::bytea, $312::bigint),($313::bytea, $314::bigint),($315::bytea, $316::bigint),($317::bytea, $318::bigint),($319::bytea, $320::bigint),($321::bytea, $322::bigint),($323::bytea, $324::bigint),($325::bytea, $326::bigint),($327::bytea, $328::bigint),($329::bytea, $330::bigint),($331::bytea, $332::bigint),($333::bytea, $334::bigint),($335::bytea, $336::bigint),($337::bytea, $338::bigint),($339::bytea, $340::bigint),($341::bytea, $342::bigint),($343::bytea, $344::bigint),($345::bytea, $346::bigint),($347::bytea, $348::bigint),($349::bytea, $350::bigint),($351::bytea, $352::bigint),($353::bytea, $354::bigint),($355::bytea, $356::bigint),($357::bytea, $358::bigint),($359::bytea, $360::bigint),($361::bytea, $362::bigint),($363::bytea, $364::bigint),($365::bytea, $366::bigint),($367::bytea, $368::bigint),($369::bytea, $370::bigint),($371::bytea, $372::bigint),($373::bytea, $374::bigint),($375::bytea, $376::bigint),($377::bytea, $378::bigint),($379::bytea, $380::bigint),($381::bytea, $382::bigint),($383::bytea, $384::bigint),($385::bytea, $386::bigint),($387::bytea, $388::bigint),($389::bytea, $390::bigint),($391::bytea, $392::bigint),($393::bytea, $394::bigint),($395::bytea, $396::bigint),($397::bytea, $398::bigint),($399::bytea, $400::bigint),($401::bytea, $402::bigint),($403::bytea, $404::bigint),($405::bytea, $406::bigint),($407::bytea, $408::bigint),($409::bytea, $410::bigint),($411::bytea, $412::bigint),($413::bytea, $414::bigint),($415::bytea, $416::bigint),($417::bytea, $418::bigint),($419::bytea, $420::bigint),($421::bytea, $422::bigint),($423::bytea, $424::bigint),($425::bytea, $426::bigint),($427::bytea, $428::bigint),($429::bytea, $430::bigint),($431::bytea, $432::bigint),($433::bytea, $434::bigint),($435::bytea, $436::bigint),($437::bytea, $438::bigint),($439::bytea, $440::bigint),($441::bytea, $442::bigint),($443::bytea, $444::bigint),($445::bytea, $446::bigint),($447::bytea, $448::bigint),($449::bytea, $450::bigint),($451::bytea, $452::bigint),($453::bytea, $454::bigint),($455::bytea, $456::bigint),($457::bytea, $458::bigint),($459::bytea, $460::bigint),($461::bytea, $462::bigint),($463::bytea, $464::bigint),($465::bytea, $466::bigint),($467::bytea, $468::bigint),($469::bytea, $470::bigint),($471::bytea, $472::bigint),($473::bytea, $474::bigint),($475::bytea, $476::bigint),($477::bytea, $478::bigint),($479::bytea, $480::bigint),($481::bytea, $482::bigint),($483::bytea, $484::bigint),($485::bytea, $486::bigint),($487::bytea, $488::bigint),($489::bytea, $490::bigint),($491::bytea, $492::bigint),($493::bytea, $494::bigint),($495::bytea, $496::bigint),($497::bytea, $498::bigint),($499::bytea, $500::bigint),($501::bytea, $502::bigint),($503::bytea, $504::bigint),($505::bytea, $506::bigint),($507::bytea, $508::bigint),($509::bytea, $510::bigint),($511::bytea, $512::bigint),($513::bytea, $514::bigint),($515::bytea, $516::bigint),($517::bytea, $518::bigint),($519::bytea, $520::bigint),($521::bytea, $522::bigint),($523::bytea, $524::bigint),($525::bytea, $526::bigint),($527::bytea, $528::bigint),($529::bytea, $530::bigint),($531::bytea, $532::bigint),($533::bytea, $534::bigint),($535::bytea, $536::bigint),($537::bytea, $538::bigint),($539::bytea, $540::bigint),($541::bytea, $542::bigint),($543::bytea, $544::bigint),($545::bytea, $546::bigint),($547::bytea, $548::bigint),($549::bytea, $550::bigint),($551::bytea, $552::bigint),($553::bytea, $554::bigint),($555::bytea, $556::bigint),($557::bytea, $558::bigint),($559::bytea, $560::bigint),($561::bytea, $562::bigint),($563::bytea, $564::bigint),($565::bytea, $566::bigint),($567::bytea, $568::bigint),($569::bytea, $570::bigint),($571::bytea, $572::bigint),($573::bytea, $574::bigint),($575::bytea, $576::bigint),($577::bytea, $578::bigint),($579::bytea, $580::bigint),($581::bytea, $582::bigint),($583::bytea, $584::bigint),($585::bytea, $586::bigint),($587::bytea, $588::bigint),($589::bytea, $590::bigint),($591::bytea, $592::bigint),($593::bytea, $594::bigint),($595::bytea, $596::bigint),($597::bytea, $598::bigint),($599::bytea, $600::bigint),($601::bytea, $602::bigint),($603::bytea, $604::bigint),($605::bytea, $606::bigint),($607::bytea, $608::bigint),($609::bytea, $610::bigint),($611::bytea, $612::bigint),($613::bytea, $614::bigint),($615::bytea, $616::bigint),($617::bytea, $618::bigint),($619::bytea, $620::bigint),($621::bytea, $622::bigint),($623::bytea, $624::bigint),($625::bytea, $626::bigint),($627::bytea, $628::bigint),($629::bytea, $630::bigint),($631::bytea, $632::bigint),($633::bytea, $634::bigint),($635::bytea, $636::bigint),($637::bytea, $638::bigint),($639::bytea, $640::bigint),($641::bytea, $642::bigint),($643::bytea, $644::bigint),($645::bytea, $646::bigint),($647::bytea, $648::bigint),($649::bytea, $650::bigint),($651::bytea, $652::bigint),($653::bytea, $654::bigint),($655::bytea, $656::bigint),($657::bytea, $658::bigint),($659::bytea, $660::bigint),($661::bytea, $662::bigint),($663::bytea, $664::bigint),($665::bytea, $666::bigint),($667::bytea, $668::bigint),($669::bytea, $670::bigint),($671::bytea, $672::bigint),($673::bytea, $674::bigint),($675::bytea, $676::bigint),($677::bytea, $678::bigint),($679::bytea, $680::bigint),($681::bytea, $682::bigint),($683::bytea, $684::bigint),($685::bytea, $686::bigint),($687::bytea, $688::bigint),($689::bytea, $690::bigint),($691::bytea, $692::bigint),($693::bytea, $694::bigint),($695::bytea, $696::bigint),($697::bytea, $698::bigint),($699::bytea, $700::bigint),($701::bytea, $702::bigint),($703::bytea, $704::bigint),($705::bytea, $706::bigint),($707::bytea, $708::bigint),($709::bytea, $710::bigint),($711::bytea, $712::bigint),($713::bytea, $714::bigint),($715::bytea, $716::bigint),($717::bytea, $71
363 min 1% 18 ms 1,196,988 hasura
SELECT SUM(transactions.transaction_input_value_satoshis)::bigint FROM (
    SELECT transaction_input_value_satoshis (transaction) FROM transaction WHERE internal_id  IN (SELECT transaction_internal_id from block_transaction WHERE block_internal_id = block_row.internal_id)
  ) as "transactions"
337 min 1% 0 ms 344,472,052 hasura
SELECT SUM(inputs.input_value_satoshis)::bigint FROM (
    SELECT input_value_satoshis (input) FROM input WHERE transaction_internal_id = transaction_row.internal_id
  ) as "inputs"
315 min 0.9% 12 ms 1,546,883 chaingraph
WITH transaction_values (hash, version, locktime, size_bytes, is_coinbase) AS (
  VALUES ($1::bytea, $2::bigint, $3::bigint, $4::bigint, $5::boolean)
), output_values (output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment) AS (
  VALUES ($6::bigint, $7::bigint, $8::bytea, $9::bytea, $10, $11, $12),($13::bigint, $14::bigint, $15::bytea, $16::bytea, $17, $18, $19)
), input_values (input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode) AS (
  VALUES ($20::bigint, $21::bigint, $22::bigint, $23::bytea, $24::bytea)
), node_transaction_values (node_internal_id, validated_at) AS (
  VALUES ($25::bigint, $26::timestamp)
), new_transaction (transaction_hash, transaction_internal_id) AS (
  INSERT INTO transaction (hash, version, locktime, size_bytes, is_coinbase)
    SELECT hash, version, locktime, size_bytes, is_coinbase FROM transaction_values
    ON CONFLICT ON CONSTRAINT "transaction_hash_key" DO NOTHING
    RETURNING hash AS transaction_hash, internal_id AS transaction_internal_id
), insert_outputs AS (
  INSERT INTO output (transaction_hash, output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment)
    SELECT transaction_hash, output_index, value_satoshis, locking_bytecode, token_category::bytea, fungible_token_amount::bigint, nonfungible_token_capability::enum_nonfungible_token_capability, nonfungible_token_commitment::bytea FROM output_values CROSS JOIN new_transaction
), insert_inputs AS (
  INSERT INTO input (transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode)
    SELECT transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode FROM input_values CROSS JOIN new_transaction
), new_or_existing_transaction (transaction_internal_id) AS (
  SELECT COALESCE (
    (SELECT transaction_internal_id FROM new_transaction),
    (SELECT internal_id AS transaction_internal_id FROM transaction WHERE transaction.hash = $27::bytea)
  )
)
INSERT INTO node_transaction (node_internal_id, transaction_internal_id, validated_at)
  SELECT node_internal_id, transaction_internal_id, validated_at FROM node_transaction_values CROSS JOIN new_or_existing_transaction
308 min 0.9% 10,127 ms 1,827 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($5, $6::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($7, $8, $9,
      $10::bytea,
      $11::bytea,
      $12::bytea,
      $13::bigint, $14::bigint, $15::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $16::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
291 min 0.9% 388 ms 45,032 hasura
SELECT  coalesce(json_agg("root" ), $3 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."locking_bytecode" AS "locking_bytecode", "_root.base"."transaction_hash" AS "transaction_hash", ("_root.base"."fungible_token_amount")::text AS "fungible_token_amount"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("public"."output"."token_category") = (($2)::bytea)) AND (NOT ((EXISTS  (SELECT  $4  FROM "public"."input" AS "__be_0_input" WHERE (((("__be_0_input"."outpoint_transaction_hash") = ("public"."output"."transaction_hash")) AND ((("__be_0_input"."outpoint_index") = ("public"."output"."output_index")) AND ($5))) AND (($6) AND (($7) AND ($8))))     )) AND ($9))))    LIMIT $10 OFFSET $11) AS "_root.base"      ) AS "_root"
267 min 0.8% 4 ms 3,685,084 chaingraph
WITH newly_spent AS (
	SELECT new_table.node_internal_id, new_table.transaction_internal_id, new_table.validated_at, input.outpoint_transaction_hash, input.outpoint_index
		FROM input INNER JOIN new_table ON input.transaction_internal_id = new_table.transaction_internal_id
),
possibly_replaced AS (
    SELECT newly_spent.node_internal_id, input.transaction_internal_id, newly_spent.validated_at as replaced_at
        FROM input INNER JOIN newly_spent ON input.outpoint_transaction_hash = newly_spent.outpoint_transaction_hash AND input.outpoint_index = newly_spent.outpoint_index
        WHERE input.transaction_internal_id != newly_spent.transaction_internal_id
),
deleted_node_transactions AS (
    DELETE FROM node_transaction
        USING possibly_replaced
        WHERE node_transaction.node_internal_id = possibly_replaced.node_internal_id
            AND node_transaction.transaction_internal_id = possibly_replaced.transaction_internal_id
        RETURNING node_transaction.node_internal_id, node_transaction.transaction_internal_id, validated_at, replaced_at
)
INSERT INTO node_transaction_history (node_internal_id, transaction_internal_id, validated_at, replaced_at)
	SELECT node_internal_id, transaction_internal_id, validated_at, replaced_at FROM deleted_node_transactions
205 min 0.6% 4 ms 2,762,732 hasura
SELECT  coalesce(json_agg("root" ), $4 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."transaction_hash" AS "transaction_hash", "_root.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", ("_root.base"."output_index")::text AS "output_index"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("public"."output"."token_category") = (($2)::bytea)) AND ((("public"."output"."nonfungible_token_capability") = (($3)::"enum_nonfungible_token_capability")) AND (NOT ((EXISTS  (SELECT  $5  FROM "public"."input" AS "__be_0_input" WHERE (((("__be_0_input"."outpoint_transaction_hash") = ("public"."output"."transaction_hash")) AND ((("__be_0_input"."outpoint_index") = ("public"."output"."output_index")) AND ($6))) AND (($7) AND (($8) AND ($9))))     )) AND ($10)))))    LIMIT $11 ) AS "_root.base"      ) AS "_root"
196 min 0.6% 291 ms 40,384 hasura
SELECT  coalesce(json_agg("root" ), $3 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("public"."transaction"."hash") = (($2)::bytea))    LIMIT $4 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $5 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $6 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead"."authhead" AS "authhead"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead.base"."hash" AS "hash"       ) AS "_e"      ) ) AS "authhead" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.authchains.base"."authhead_transaction_hash") = ("hash"))    LIMIT $7 ) AS "_root.ar.root.authchains.or.authhead.base"      ) AS "_root.ar.root.authchains.or.authhead" ON ($8)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($9)      ) AS "_root"
181 min 0.5% 29,048 ms 373 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($7, $8::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($9, $10, $11,
      $12::bytea,
      $13::bytea,
      $14::bytea,
      $15::bigint, $16::bigint, $17::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $18::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
138 min 0.4% 41 ms 203,860 hasura
SELECT  "_subs"."result_id" , "_fld_resp"."root" AS "result" FROM UNNEST(($1)::uuid[], ($2)::json[]) AS "_subs"("result_id", "result_vars") LEFT OUTER JOIN LATERAL (SELECT  json_build_object($3, "node"."root" ) AS "root" FROM  (SELECT  coalesce(json_agg("root" ), $4 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."name" AS "name", "_root.base"."user_agent" AS "user_agent", ("public"."node_unconfirmed_transaction_count"("_root.base") )::text AS "unconfirmed_transaction_count", "_root.ar.root.unconfirmed_transactions"."unconfirmed_transactions" AS "unconfirmed_transactions", $5 AS "__typename"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."node"  WHERE (("public"."node"."name") ~ ((("_subs"."result_vars"#>>ARRAY[$6, $7]))::text))    LIMIT $8 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."unconfirmed_transactions" ORDER BY "ob_col_1" DESC NULLS FIRST), $9 )  FROM  (SELECT  "_unnest_table"."unconfirmed_transactions" AS "unconfirmed_transactions", "_unnest_table"."ob_col_1" AS "ob_col_1" FROM UNNEST(array_agg("unconfirmed_transactions" ), array_agg("root.ar.root.unconfirmed_transactions.pg.validated_at" )) AS "_unnest_table"("unconfirmed_transactions", "ob_col_1")    ORDER BY "ob_col_1" DESC NULLS FIRST LIMIT $10 ) AS "_sub_query"      ) AS "unconfirmed_transactions" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.unconfirmed_transactions.base"."validated_at" AS "validated_at", "_root.ar.root.unconfirmed_transactions.or.transaction"."transaction" AS "transaction", $11 AS "__typename"       ) AS "_e"      ) ) AS "unconfirmed_transactions", "_root.ar.root.unconfirmed_transactions.base"."validated_at" AS "root.ar.root.unconfirmed_transactions.pg.validated_at" FROM  (SELECT  *  FROM "public"."node_transaction"  WHERE (("_root.base"."internal_id") = ("node_internal_id"))   ORDER BY "validated_at" DESC NULLS FIRST LIMIT $12 OFFSET $13) AS "_root.ar.root.unconfirmed_transactions.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.unconfirmed_transactions.or.transaction.base"."hash" AS "hash", ("public"."transaction_input_value_satoshis"("_root.ar.root.unconfirmed_transactions.or.transaction.base") )::text AS "input_value_satoshis", ("public"."transaction_output_value_satoshis"("_root.ar.root.unconfirmed_transactions.or.transaction.base") )::text AS "output_value_satoshis", "_root.ar.root.unconfirmed_transactions.or.transaction.base"."is_coinbase" AS "is_coinbase", "md5_b6cc12c09542ad52ba9b87baa9b812ef__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_408769f88a061e776e7caeed495b93f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs"."outputs" AS "outputs", $14 AS "__typename"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.unconfirmed_transactions.base"."transaction_internal_id") = ("internal_id"))    LIMIT $15 ) AS "_root.ar.root.unconfirmed_transactions.or.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $16 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $17 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."token_category" AS "token_category", ("md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."fungible_token_amount")::text AS "fungible_token_amount", "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode", ("md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."value_satoshis")::text AS "value_satoshis", $18 AS "__typename"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE (("_root.ar.root.unconfirmed_transactions.or.transaction.base"."hash") = ("transaction_hash"))     ) AS "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"      ) AS "md5_408769f88a061e776e7caeed495b93f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs"      ) AS "md5_408769f88a061e776e7caeed495b93f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs" ON ($19) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $20 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $21 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_449b6821e778500d7dd8178a97963065__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint"."outpoint" AS "outpoint", $22 AS "__typename"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE (("_root.ar.root.unconfirmed_transactions.or.transaction.base"."internal_id") = ("transaction_internal_id"))     ) AS "md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."token_category" AS "token_category", ("md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."fungible_token_amount")::text AS "fungible_token_amount", "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."locking_bytecode" AS "locking_bytecode", ("md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."value_satoshis")::text AS "value_satoshis", $23 AS "__typename"       ) AS "_e"      ) ) AS "outpoint" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base"."outpoint_index") = ("output_index")) AND (("md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base"."outpoint_transaction_hash") = ("transaction_hash")))    LIMIT $24 ) AS "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"      ) AS "md5_449b6821e778500d7dd8178a97963065__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint" ON ($25)      ) AS "md5_b6cc12c09542ad52ba9b87baa9b812ef__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs"      ) AS "md5_b6cc12c09542ad52ba9b87baa9b812ef__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs" ON ($26)      ) AS "_root.ar.root.unconfirmed_transactions.or.transaction" ON ($27)    ORDER BY "root.ar.root.unconfirmed_transactions.pg.validated_at" DESC NULLS FIRST  ) AS "_root.ar.root.unconfirmed_transactions"      ) AS "_root.ar.root.unconfirmed_transactions" ON ($28)      ) AS "_root"      ) AS "node"      ) AS "_fld_resp" ON ($29)
138 min 0.4% 3 ms 2,394,059 hasura
SELECT SUM(transactions.transaction_output_value_satoshis)::bigint FROM (
    SELECT transaction_output_value_satoshis (transaction) FROM transaction WHERE internal_id  IN (SELECT transaction_internal_id from block_transaction WHERE block_internal_id = block_row.internal_id)
  ) as "transactions"
129 min 0.4% 1 ms 14,338,761 hasura
SELECT  coalesce(json_agg("root" ), $5 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."transaction_hash" AS "transaction_hash", ("_root.base"."output_index")::text AS "output_index", ("_root.base"."value_satoshis")::text AS "value_satoshis", "_root.base"."token_category" AS "token_category", ("_root.base"."fungible_token_amount")::text AS "fungible_token_amount", "_root.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "_root.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "_root.base"."locking_bytecode" AS "locking_bytecode", "_root.or.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."search_output"(($2)::_text) AS "_search_output" WHERE (((EXISTS  (SELECT  $6  FROM "public"."transaction" AS "__be_0_transaction" WHERE (((("__be_0_transaction"."hash") = ("_search_output"."transaction_hash")) AND ($7)) AND (($8) AND (((EXISTS  (SELECT  $9  FROM "public"."node_transaction" AS "__be_1_node_transaction" WHERE (((("__be_1_node_transaction"."transaction_internal_id") = ("__be_0_transaction"."internal_id")) AND ($10)) AND (($11) AND (((EXISTS  (SELECT  $12  FROM "public"."node" AS "__be_2_node" WHERE (((("__be_2_node"."internal_id") = ("__be_1_node_transaction"."node_internal_id")) AND ($13)) AND (($14) AND ((((("__be_2_node"."name") LIKE (($3)::text)) AND ($15)) AND ($16)) AND ($17))))     )) AND ($18)) AND ($19))))     )) AND ($20)) AND ($21))))     )) OR (EXISTS  (SELECT  $22  FROM "public"."transaction" AS "__be_3_transaction" WHERE (((("__be_3_transaction"."hash") = ("_search_output"."transaction_hash")) AND ($23)) AND (($24) AND (((EXISTS  (SELECT  $25  FROM "public"."block_transaction" AS "__be_4_block_transaction" WHERE (((("__be_4_block_transaction"."transaction_internal_id") = ("__be_3_transaction"."internal_id")) AND ($26)) AND (($27) AND (((EXISTS  (SELECT  $28  FROM "public"."block" AS "__be_5_block" WHERE (((("__be_5_block"."internal_id") = ("__be_4_block_transaction"."block_internal_id")) AND ($29)) AND (($30) AND (((EXISTS  (SELECT  $31  FROM "public"."node_block" AS "__be_6_node_block" WHERE (((("__be_6_node_block"."block_internal_id") = ("__be_5_block"."internal_id")) AND ($32)) AND (($33) AND (((EXISTS  (SELECT  $34  FROM "public"."node" AS "__be_7_node" WHERE (((("__be_7_node"."internal_id") = ("__be_6_node_block"."node_internal_id")) AND ($35)) AND (($36) AND ((((("__be_7_node"."name") LIKE (($4)::text)) AND ($37)) AND ($38)) AND ($39))))     )) AND ($40)) AND ($41))))     )) AND ($42)) AND ($43))))     )) AND ($44)) AND ($45))))     )) AND ($46)) AND ($47))))     ))) AND (NOT ((EXISTS  (SELECT  $48  FROM "public"."input" AS "__be_8_input" WHERE (((("__be_8_input"."outpoint_transaction_hash") = ("_search_output"."transaction_hash")) AND ((("__be_8_input"."outpoint_index") = ("_search_output"."output_index")) AND ($49))) AND (($50) AND (($51) AND ($52))))     )) AND ($53))))    LIMIT $54 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.transaction.ar.transaction.block_inclusions"."block_inclusions" AS "block_inclusions"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.base"."transaction_hash") = ("hash"))    LIMIT $55 ) AS "_root.or.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."block_inclusions" ), $56 )  FROM  (SELECT  "_unnest_table"."block_inclusions" AS "block_inclusions" FROM UNNEST(array_agg("block_inclusions" )) AS "_unnest_table"("block_inclusions")     LIMIT $57 ) AS "_sub_query"      ) AS "block_inclusions" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.transaction.ar.transaction.block_inclusions.or.block"."block" AS "block"       ) AS "_e"      ) ) AS "block_inclusions" FROM  (SELECT  *  FROM "public"."block_transaction"  WHERE (("_root.or.transaction.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.or.transaction.ar.transaction.block_inclusions.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_9162a994ed01d228d2df70c16d46d784__root.or.transaction.ar.transaction.block_inclusions.or.block.base"."height")::text AS "height"       ) AS "_e"      ) ) AS "block" FROM  (SELECT  *  FROM "public"."block"  WHERE (("_root.or.transaction.ar.transaction.block_inclusions.base"."block_internal_id") = ("internal_id"))    LIMIT $58 ) AS "md5_9162a994ed01d228d2df70c16d46d784__root.or.transaction.ar.transaction.block_inclusions.or.block.base"      ) AS "_root.or.transaction.ar.transaction.block_inclusions.or.block" ON ($59)      ) AS "_root.or.transaction.ar.transaction.block_inclusions"      ) AS "_root.or.transaction.ar.transaction.block_inclusions" ON ($60)      ) AS "_root.or.transaction" ON ($61)      ) AS "_root"
117 min 0.4% 8 ms 842,619 chaingraph
WITH transaction_values (hash, version, locktime, size_bytes, is_coinbase) AS (
  VALUES ($1::bytea, $2::bigint, $3::bigint, $4::bigint, $5::boolean)
), output_values (output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment) AS (
  VALUES ($6::bigint, $7::bigint, $8::bytea, $9::bytea, $10, $11, $12),($13::bigint, $14::bigint, $15::bytea, $16::bytea, $17, $18, $19),($20::bigint, $21::bigint, $22::bytea, $23::bytea, $24, $25, $26)
), input_values (input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode) AS (
  VALUES ($27::bigint, $28::bigint, $29::bigint, $30::bytea, $31::bytea),($32::bigint, $33::bigint, $34::bigint, $35::bytea, $36::bytea)
), node_transaction_values (node_internal_id, validated_at) AS (
  VALUES ($37::bigint, $38::timestamp)
), new_transaction (transaction_hash, transaction_internal_id) AS (
  INSERT INTO transaction (hash, version, locktime, size_bytes, is_coinbase)
    SELECT hash, version, locktime, size_bytes, is_coinbase FROM transaction_values
    ON CONFLICT ON CONSTRAINT "transaction_hash_key" DO NOTHING
    RETURNING hash AS transaction_hash, internal_id AS transaction_internal_id
), insert_outputs AS (
  INSERT INTO output (transaction_hash, output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment)
    SELECT transaction_hash, output_index, value_satoshis, locking_bytecode, token_category::bytea, fungible_token_amount::bigint, nonfungible_token_capability::enum_nonfungible_token_capability, nonfungible_token_commitment::bytea FROM output_values CROSS JOIN new_transaction
), insert_inputs AS (
  INSERT INTO input (transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode)
    SELECT transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode FROM input_values CROSS JOIN new_transaction
), new_or_existing_transaction (transaction_internal_id) AS (
  SELECT COALESCE (
    (SELECT transaction_internal_id FROM new_transaction),
    (SELECT internal_id AS transaction_internal_id FROM transaction WHERE transaction.hash = $39::bytea)
  )
)
INSERT INTO node_transaction (node_internal_id, transaction_internal_id, validated_at)
  SELECT node_internal_id, transaction_internal_id, validated_at FROM node_transaction_values CROSS JOIN new_or_existing_transaction
101 min 0.3% 0 ms 14,341,076 hasura
(SELECT * FROM output
  -- use output_locking_bytecode_prefix_index
  WHERE substring(locking_bytecode from $4 for $5)
  = ANY(decoded)
  ORDER BY locking_bytecode ASC)
92 min 0.3% 789,255 ms 7 chaingraph
WITH unknown_transaction_values (hash, version, locktime, size_bytes, is_coinbase) AS (
  VALUES ($1::bytea, $2::bigint, $3::bigint, $4::bigint, $5::boolean),($6::bytea, $7::bigint, $8::bigint, $9::bigint, $10::boolean),($11::bytea, $12::bigint, $13::bigint, $14::bigint, $15::boolean),($16::bytea, $17::bigint, $18::bigint, $19::bigint, $20::boolean),($21::bytea, $22::bigint, $23::bigint, $24::bigint, $25::boolean),($26::bytea, $27::bigint, $28::bigint, $29::bigint, $30::boolean),($31::bytea, $32::bigint, $33::bigint, $34::bigint, $35::boolean),($36::bytea, $37::bigint, $38::bigint, $39::bigint, $40::boolean),($41::bytea, $42::bigint, $43::bigint, $44::bigint, $45::boolean),($46::bytea, $47::bigint, $48::bigint, $49::bigint, $50::boolean),($51::bytea, $52::bigint, $53::bigint, $54::bigint, $55::boolean),($56::bytea, $57::bigint, $58::bigint, $59::bigint, $60::boolean),($61::bytea, $62::bigint, $63::bigint, $64::bigint, $65::boolean),($66::bytea, $67::bigint, $68::bigint, $69::bigint, $70::boolean),($71::bytea, $72::bigint, $73::bigint, $74::bigint, $75::boolean),($76::bytea, $77::bigint, $78::bigint, $79::bigint, $80::boolean),($81::bytea, $82::bigint, $83::bigint, $84::bigint, $85::boolean),($86::bytea, $87::bigint, $88::bigint, $89::bigint, $90::boolean),($91::bytea, $92::bigint, $93::bigint, $94::bigint, $95::boolean),($96::bytea, $97::bigint, $98::bigint, $99::bigint, $100::boolean),($101::bytea, $102::bigint, $103::bigint, $104::bigint, $105::boolean),($106::bytea, $107::bigint, $108::bigint, $109::bigint, $110::boolean),($111::bytea, $112::bigint, $113::bigint, $114::bigint, $115::boolean),($116::bytea, $117::bigint, $118::bigint, $119::bigint, $120::boolean),($121::bytea, $122::bigint, $123::bigint, $124::bigint, $125::boolean),($126::bytea, $127::bigint, $128::bigint, $129::bigint, $130::boolean),($131::bytea, $132::bigint, $133::bigint, $134::bigint, $135::boolean),($136::bytea, $137::bigint, $138::bigint, $139::bigint, $140::boolean),($141::bytea, $142::bigint, $143::bigint, $144::bigint, $145::boolean),($146::bytea, $147::bigint, $148::bigint, $149::bigint, $150::boolean),($151::bytea, $152::bigint, $153::bigint, $154::bigint, $155::boolean),($156::bytea, $157::bigint, $158::bigint, $159::bigint, $160::boolean),($161::bytea, $162::bigint, $163::bigint, $164::bigint, $165::boolean),($166::bytea, $167::bigint, $168::bigint, $169::bigint, $170::boolean),($171::bytea, $172::bigint, $173::bigint, $174::bigint, $175::boolean),($176::bytea, $177::bigint, $178::bigint, $179::bigint, $180::boolean),($181::bytea, $182::bigint, $183::bigint, $184::bigint, $185::boolean),($186::bytea, $187::bigint, $188::bigint, $189::bigint, $190::boolean),($191::bytea, $192::bigint, $193::bigint, $194::bigint, $195::boolean),($196::bytea, $197::bigint, $198::bigint, $199::bigint, $200::boolean),($201::bytea, $202::bigint, $203::bigint, $204::bigint, $205::boolean),($206::bytea, $207::bigint, $208::bigint, $209::bigint, $210::boolean),($211::bytea, $212::bigint, $213::bigint, $214::bigint, $215::boolean),($216::bytea, $217::bigint, $218::bigint, $219::bigint, $220::boolean),($221::bytea, $222::bigint, $223::bigint, $224::bigint, $225::boolean),($226::bytea, $227::bigint, $228::bigint, $229::bigint, $230::boolean),($231::bytea, $232::bigint, $233::bigint, $234::bigint, $235::boolean),($236::bytea, $237::bigint, $238::bigint, $239::bigint, $240::boolean),($241::bytea, $242::bigint, $243::bigint, $244::bigint, $245::boolean),($246::bytea, $247::bigint, $248::bigint, $249::bigint, $250::boolean),($251::bytea, $252::bigint, $253::bigint, $254::bigint, $255::boolean),($256::bytea, $257::bigint, $258::bigint, $259::bigint, $260::boolean),($261::bytea, $262::bigint, $263::bigint, $264::bigint, $265::boolean),($266::bytea, $267::bigint, $268::bigint, $269::bigint, $270::boolean),($271::bytea, $272::bigint, $273::bigint, $274::bigint, $275::boolean),($276::bytea, $277::bigint, $278::bigint, $279::bigint, $280::boolean),($281::bytea, $282::bigint, $283::bigint, $284::bigint, $285::boolean),($286::bytea, $287::bigint, $288::bigint, $289::bigint, $290::boolean),($291::bytea, $292::bigint, $293::bigint, $294::bigint, $295::boolean),($296::bytea, $297::bigint, $298::bigint, $299::bigint, $300::boolean),($301::bytea, $302::bigint, $303::bigint, $304::bigint, $305::boolean),($306::bytea, $307::bigint, $308::bigint, $309::bigint, $310::boolean),($311::bytea, $312::bigint, $313::bigint, $314::bigint, $315::boolean),($316::bytea, $317::bigint, $318::bigint, $319::bigint, $320::boolean),($321::bytea, $322::bigint, $323::bigint, $324::bigint, $325::boolean),($326::bytea, $327::bigint, $328::bigint, $329::bigint, $330::boolean),($331::bytea, $332::bigint, $333::bigint, $334::bigint, $335::boolean),($336::bytea, $337::bigint, $338::bigint, $339::bigint, $340::boolean),($341::bytea, $342::bigint, $343::bigint, $344::bigint, $345::boolean),($346::bytea, $347::bigint, $348::bigint, $349::bigint, $350::boolean),($351::bytea, $352::bigint, $353::bigint, $354::bigint, $355::boolean),($356::bytea, $357::bigint, $358::bigint, $359::bigint, $360::boolean),($361::bytea, $362::bigint, $363::bigint, $364::bigint, $365::boolean),($366::bytea, $367::bigint, $368::bigint, $369::bigint, $370::boolean),($371::bytea, $372::bigint, $373::bigint, $374::bigint, $375::boolean),($376::bytea, $377::bigint, $378::bigint, $379::bigint, $380::boolean),($381::bytea, $382::bigint, $383::bigint, $384::bigint, $385::boolean),($386::bytea, $387::bigint, $388::bigint, $389::bigint, $390::boolean),($391::bytea, $392::bigint, $393::bigint, $394::bigint, $395::boolean),($396::bytea, $397::bigint, $398::bigint, $399::bigint, $400::boolean),($401::bytea, $402::bigint, $403::bigint, $404::bigint, $405::boolean),($406::bytea, $407::bigint, $408::bigint, $409::bigint, $410::boolean),($411::bytea, $412::bigint, $413::bigint, $414::bigint, $415::boolean),($416::bytea, $417::bigint, $418::bigint, $419::bigint, $420::boolean),($421::bytea, $422::bigint, $423::bigint, $424::bigint, $425::boolean),($426::bytea, $427::bigint, $428::bigint, $429::bigint, $430::boolean),($431::bytea, $432::bigint, $433::bigint, $434::bigint, $435::boolean),($436::bytea, $437::bigint, $438::bigint, $439::bigint, $440::boolean),($441::bytea, $442::bigint, $443::bigint, $444::bigint, $445::boolean),($446::bytea, $447::bigint, $448::bigint, $449::bigint, $450::boolean),($451::bytea, $452::bigint, $453::bigint, $454::bigint, $455::boolean),($456::bytea, $457::bigint, $458::bigint, $459::bigint, $460::boolean),($461::bytea, $462::bigint, $463::bigint, $464::bigint, $465::boolean),($466::bytea, $467::bigint, $468::bigint, $469::bigint, $470::boolean),($471::bytea, $472::bigint, $473::bigint, $474::bigint, $475::boolean),($476::bytea, $477::bigint, $478::bigint, $479::bigint, $480::boolean),($481::bytea, $482::bigint, $483::bigint, $484::bigint, $485::boolean),($486::bytea, $487::bigint, $488::bigint, $489::bigint, $490::boolean),($491::bytea, $492::bigint, $493::bigint, $494::bigint, $495::boolean),($496::bytea, $497::bigint, $498::bigint, $499::bigint, $500::boolean),($501::bytea, $502::bigint, $503::bigint, $504::bigint, $505::boolean),($506::bytea, $507::bigint, $508::bigint, $509::bigint, $510::boolean),($511::bytea, $512::bigint, $513::bigint, $514::bigint, $515::boolean),($516::bytea, $517::bigint, $518::bigint, $519::bigint, $520::boolean),($521::bytea, $522::bigint, $523::bigint, $524::bigint, $525::boolean),($526::bytea, $527::bigint, $528::bigint, $529::bigint, $530::boolean),($531::bytea, $532::bigint, $533::bigint, $534::bigint, $535::boolean),($536::bytea, $537::bigint, $538::bigint, $539::bigint, $540::boolean),($541::bytea, $542::bigint, $543::bigint, $544::bigint, $545::boolean),($546::bytea, $547::bigint, $548::bigint, $549::bigint, $550::boolean),($551::bytea, $552::bigint, $553::bigint, $554::bigint, $555::boolean),($556::bytea, $557::bigint, $558::bigint, $559::bigint, $560::boolean),($561::bytea, $562::bigint, $563::bigint, $564::bigint, $565::boolean),($566::bytea, $567::bigint, $568::bigint, $569::bigint, $570::boolean),($571::bytea, $572::bigint, $573::bigint, $574::bigint, $575::boolean),($576::bytea, $577::bigint, $578::bigint, $579::bigint, $580::boolean),($581::bytea, $582::bigint, $583::bigint, $584::bigint, $585::boolean),($586::bytea, $587::bigint, $588::bigint, $589::bigint, $590::boolean),($591::bytea, $592::bigint, $593::bigint, $594::bigint, $595::boolean),($596::bytea, $597::bigint, $598::bigint, $599::bigint, $600::boolean),($601::bytea, $602::bigint, $603::bigint, $604::bigint, $605::boolean),($606::bytea, $607::bigint, $608::bigint, $609::bigint, $610::boolean),($611::bytea, $612::bigint, $613::bigint, $614::bigint, $615::boolean),($616::bytea, $617::bigint, $618::bigint, $619::bigint, $620::boolean),($621::bytea, $622::bigint, $623::bigint, $624::bigint, $625::boolean),($626::bytea, $627::bigint, $628::bigint, $629::bigint, $630::boolean),($631::bytea, $632::bigint, $633::bigint, $634::bigint, $635::boolean),($636::bytea, $637::bigint, $638::bigint, $639::bigint, $640::boolean),($641::bytea, $642::bigint, $643::bigint, $644::bigint, $645::boolean),($646::bytea, $647::bigint, $648::bigint, $649::bigint, $650::boolean),($651::bytea, $652::bigint, $653::bigint, $654::bigint, $655::boolean),($656::bytea, $657::bigint, $658::bigint, $659::bigint, $660::boolean),($661::bytea, $662::bigint, $663::bigint, $664::bigint, $665::boolean),($666::bytea, $667::bigint, $668::bigint, $669::bigint, $670::boolean),($671::bytea, $672::bigint, $673::bigint, $674::bigint, $675::boolean),($676::bytea, $677::bigint, $678::bigint, $679::bigint, $680::boolean),($681::bytea, $682::bigint, $683::bigint, $684::bigint, $685::boolean),($686::bytea, $687::bigint, $688::bigint, $689::bigint, $690::boolean),($691::bytea, $692::bigint, $693::bigint, $694::bigint, $695::boolean),($696::bytea, $697::bigint, $698::bigint, $699::bigint, $700::boolean),($701::bytea, $702::bigint, $703::bigint, $704::bigint, $705::boolean),
87 min 0.3% 0 ms 701,881,306 hasura
SELECT value_satoshis from output
    WHERE output.transaction_hash = input_row.outpoint_transaction_hash AND
          output.output_index = input_row.outpoint_index
    LIMIT $2
76 min 0.2% 26,033 ms 176 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($9, $10::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($11, $12, $13,
      $14::bytea,
      $15::bytea,
      $16::bytea,
      $17::bigint, $18::bigint, $19::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $20::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
73 min 0.2% 4 ms 1,197,041 hasura
SELECT SUM(transactions.transaction_output_count)::bigint FROM (
    SELECT transaction_output_count (transaction) FROM transaction WHERE internal_id  IN (SELECT transaction_internal_id from block_transaction WHERE block_internal_id = block_row.internal_id)
  ) as "transactions"
68 min 0.2% 0 ms 685,362,542 hasura
SELECT SUM(value_satoshis)::bigint FROM output
  WHERE output.transaction_hash = transaction_row.hash
50 min 0.2% 3 ms 1,197,046 hasura
SELECT SUM(transactions.transaction_input_count)::bigint FROM (
    SELECT transaction_input_count (transaction) FROM transaction WHERE internal_id  IN (SELECT transaction_internal_id from block_transaction WHERE block_internal_id = block_row.internal_id)
  ) as "transactions"
45 min 0.1% 41,811 ms 65 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($13, $14::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($15, $16, $17,
      $18::bytea,
      $19::bytea,
      $20::bytea,
      $21::bigint, $22::bigint, $23::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $24::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
45 min 0.1% 6 ms 460,887 chaingraph
WITH transaction_values (hash, version, locktime, size_bytes, is_coinbase) AS (
  VALUES ($1::bytea, $2::bigint, $3::bigint, $4::bigint, $5::boolean)
), output_values (output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment) AS (
  VALUES ($6::bigint, $7::bigint, $8::bytea, $9::bytea, $10, $11, $12),($13::bigint, $14::bigint, $15::bytea, $16::bytea, $17, $18, $19),($20::bigint, $21::bigint, $22::bytea, $23::bytea, $24, $25, $26)
), input_values (input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode) AS (
  VALUES ($27::bigint, $28::bigint, $29::bigint, $30::bytea, $31::bytea)
), node_transaction_values (node_internal_id, validated_at) AS (
  VALUES ($32::bigint, $33::timestamp)
), new_transaction (transaction_hash, transaction_internal_id) AS (
  INSERT INTO transaction (hash, version, locktime, size_bytes, is_coinbase)
    SELECT hash, version, locktime, size_bytes, is_coinbase FROM transaction_values
    ON CONFLICT ON CONSTRAINT "transaction_hash_key" DO NOTHING
    RETURNING hash AS transaction_hash, internal_id AS transaction_internal_id
), insert_outputs AS (
  INSERT INTO output (transaction_hash, output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment)
    SELECT transaction_hash, output_index, value_satoshis, locking_bytecode, token_category::bytea, fungible_token_amount::bigint, nonfungible_token_capability::enum_nonfungible_token_capability, nonfungible_token_commitment::bytea FROM output_values CROSS JOIN new_transaction
), insert_inputs AS (
  INSERT INTO input (transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode)
    SELECT transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode FROM input_values CROSS JOIN new_transaction
), new_or_existing_transaction (transaction_internal_id) AS (
  SELECT COALESCE (
    (SELECT transaction_internal_id FROM new_transaction),
    (SELECT internal_id AS transaction_internal_id FROM transaction WHERE transaction.hash = $34::bytea)
  )
)
INSERT INTO node_transaction (node_internal_id, transaction_internal_id, validated_at)
  SELECT node_internal_id, transaction_internal_id, validated_at FROM node_transaction_values CROSS JOIN new_or_existing_transaction
40 min 0.1% 607 ms 3,943 hasura
SELECT  coalesce(json_agg("root" ), $4 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("public"."transaction"."hash") = (($3)::bytea))    LIMIT $5 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $6 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $7 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead"."authhead" AS "authhead", "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length", "_root.ar.root.authchains.ar.authchains.migrations"."migrations" AS "migrations"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead.base"."hash" AS "hash"       ) AS "_e"      ) ) AS "authhead" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.authchains.base"."authhead_transaction_hash") = ("hash"))    LIMIT $8 ) AS "_root.ar.root.authchains.or.authhead.base"      ) AS "_root.ar.root.authchains.or.authhead" ON ($9) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."migrations" ORDER BY "ob_col_1" DESC NULLS FIRST), $10 )  FROM  (SELECT  "_unnest_table"."migrations" AS "migrations", "_unnest_table"."ob_col_1" AS "ob_col_1" FROM UNNEST(array_agg("migrations" ), array_agg("md5_3e9df6841b24f1f40a5034f7fc1c5d8d_root.ar.root.authchains.ar.authchains.migrations.pg.migration_index" )) AS "_unnest_table"("migrations", "ob_col_1")    ORDER BY "ob_col_1" DESC NULLS FIRST LIMIT $11 ) AS "_sub_query"      ) AS "migrations" FROM  (SELECT  "_root.ar.root.authchains.ar.authchains.migrations.base"."migration_index" AS "md5_3e9df6841b24f1f40a5034f7fc1c5d8d_root.ar.root.authchains.ar.authchains.migrations.pg.migration_index", row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "migrations" FROM  (SELECT  *  FROM "public"."authchain_migrations_view"  WHERE (("_root.ar.root.authchains.base"."transaction_internal_id") = ("authbase_internal_id"))   ORDER BY "migration_index" DESC NULLS FIRST  ) AS "_root.ar.root.authchains.ar.authchains.migrations.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("transaction" ), $12 ) AS "transaction" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash" AS "hash", "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."authchain_migration_transaction"("_root.ar.root.authchains.ar.authchains.migrations.base") AS "_authchain_migration_transaction" WHERE ($13)    LIMIT $14 ) AS "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $15 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $16 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE (("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash") = ("transaction_hash"))     ) AS "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs" ON ($17) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $18 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $19 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"."outpoint_index")::text AS "outpoint_index"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."internal_id") = ("transaction_internal_id")) AND (("public"."input"."outpoint_index") = (($2)::bigint)))     ) AS "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs" ON ($20)      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction" ON ($21)    ORDER BY "md5_3e9df6841b24f1f40a5034f7fc1c5d8d_root.ar.root.authchains.ar.authchains.migrations.pg.migration_index" DESC NULLS FIRST  ) AS "_root.ar.root.authchains.ar.authchains.migrations"      ) AS "_root.ar.root.authchains.ar.authchains.migrations" ON ($22)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($23)      ) AS "_root"
40 min 0.1% 6,042 ms 394 hasura
SELECT  coalesce(json_agg("root" ORDER BY "root.or.block.pg.height" DESC NULLS FIRST), $4 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.block"."block" AS "block", "_root.or.transaction"."transaction" AS "transaction", $5 AS "__typename"       ) AS "_e"      ) ) AS "root", "_root.or.block"."root.or.block.pg.height" AS "root.or.block.pg.height" FROM  (SELECT  *  FROM "public"."block_transaction"  WHERE ((EXISTS  (SELECT  $6  FROM "public"."transaction" AS "__be_0_transaction" WHERE (((("__be_0_transaction"."internal_id") = ("public"."block_transaction"."transaction_internal_id")) AND ($7)) AND (($8) AND (((EXISTS  (SELECT  $9  FROM "public"."output" AS "__be_1_output" WHERE (((("__be_1_output"."transaction_hash") = ("__be_0_transaction"."hash")) AND ($10)) AND (($11) AND ((((("__be_1_output"."token_category") = (($2)::bytea)) AND ($12)) AND ($13)) AND ($14))))     )) AND ($15)) AND ($16))))     )) AND (EXISTS  (SELECT  $17  FROM "public"."block" AS "__be_2_block" WHERE (((("__be_2_block"."internal_id") = ("public"."block_transaction"."block_internal_id")) AND ($18)) AND (($19) AND (((EXISTS  (SELECT  $20  FROM "public"."node_block" AS "__be_3_node_block" WHERE (((("__be_3_node_block"."block_internal_id") = ("__be_2_block"."internal_id")) AND ($21)) AND (($22) AND (((EXISTS  (SELECT  $23  FROM "public"."node" AS "__be_4_node" WHERE (((("__be_4_node"."internal_id") = ("__be_3_node_block"."node_internal_id")) AND ($24)) AND (($25) AND ((((("__be_4_node"."name") ~ (($3)::text)) AND ($26)) AND ($27)) AND ($28))))     )) AND ($29)) AND ($30))))     )) AND ($31)) AND ($32))))     )))     ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.or.transaction.base"."hash" AS "hash", ("public"."transaction_input_value_satoshis"("_root.or.transaction.base") )::text AS "input_value_satoshis", ("public"."transaction_output_value_satoshis"("_root.or.transaction.base") )::text AS "output_value_satoshis", $33 AS "__typename"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.base"."transaction_internal_id") = ("internal_id"))    LIMIT $34 ) AS "_root.or.transaction.base"      ) AS "_root.or.transaction" ON ($35) LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.or.block.base"."height")::text AS "height", ("_root.or.block.base"."timestamp")::text AS "timestamp", $36 AS "__typename"       ) AS "_e"      ) ) AS "block", "_root.or.block.base"."height" AS "root.or.block.pg.height" FROM  (SELECT  *  FROM "public"."block"  WHERE (("_root.base"."block_internal_id") = ("internal_id"))    LIMIT $37 ) AS "_root.or.block.base"      ) AS "_root.or.block" ON ($38)    ORDER BY "root.or.block.pg.height" DESC NULLS FIRST LIMIT $39 OFFSET $40) AS "_root"
38 min 0.1% 0 ms 340,793,419 hasura
SELECT COUNT(*) from output WHERE output.transaction_hash = transaction_row.hash
30 min < 0.1% 38,089 ms 48 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($33, $34::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($35, $36, $37,
      $38::bytea,
      $39::bytea,
      $40::bytea,
      $41::bigint, $42::bigint, $43::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $44::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
30 min < 0.1% 38,814 ms 47 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($29, $30::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($31, $32, $33,
      $34::bytea,
      $35::bytea,
      $36::bytea,
      $37::bigint, $38::bigint, $39::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $40::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
30 min < 0.1% 24,607 ms 74 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($49, $50::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($51, $52, $53,
      $54::bytea,
      $55::bytea,
      $56::bytea,
      $57::bigint, $58::bigint, $59::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $60::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
30 min < 0.1% 40,317 ms 45 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint),($113::bytea, $114::bigint),($115::bytea, $116::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($117, $118::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($119, $120, $121,
      $122::bytea,
      $123::bytea,
      $124::bytea,
      $125::bigint, $126::bigint, $127::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $128::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
30 min < 0.1% 61,989 ms 29 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($61, $62::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($63, $64, $65,
      $66::bytea,
      $67::bytea,
      $68::bytea,
      $69::bigint, $70::bigint, $71::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $72::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
30 min < 0.1% 942 ms 1,902 hasura
SELECT  coalesce(json_agg("root" ), $8 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains", $9 AS "__typename"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE ((EXISTS  (SELECT  $10  FROM "public"."block_transaction" AS "__be_0_block_transaction" WHERE (((("__be_0_block_transaction"."transaction_internal_id") = ("public"."transaction"."internal_id")) AND ($11)) AND (($12) AND (((EXISTS  (SELECT  $13  FROM "public"."block" AS "__be_1_block" WHERE (((("__be_1_block"."internal_id") = ("__be_0_block_transaction"."block_internal_id")) AND ($14)) AND (($15) AND (((EXISTS  (SELECT  $16  FROM "public"."node_block" AS "__be_2_node_block" WHERE (((("__be_2_node_block"."block_internal_id") = ("__be_1_block"."internal_id")) AND ($17)) AND (($18) AND (((EXISTS  (SELECT  $19  FROM "public"."node" AS "__be_3_node" WHERE (((("__be_3_node"."internal_id") = ("__be_2_node_block"."node_internal_id")) AND ($20)) AND (($21) AND ((((("__be_3_node"."name") ~ (($6)::text)) AND ($22)) AND ($23)) AND ($24))))     )) AND ($25)) AND ($26))))     )) AND ($27)) AND ($28))))     )) AND ($29)) AND ($30))))     )) AND (("public"."transaction"."hash") = ANY(($7)::bytea[])))    LIMIT $31 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $32 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $33 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length", "_root.ar.root.authchains.or.authhead"."authhead" AS "authhead", "_root.ar.root.authchains.ar.authchains.migrations"."migrations" AS "migrations", $34 AS "__typename"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead.base"."hash" AS "hash", "_root.ar.root.authchains.or.authhead.cf.identity_output"."identity_output" AS "identity_output", $35 AS "__typename"       ) AS "_e"      ) ) AS "authhead" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.authchains.base"."authhead_transaction_hash") = ("hash"))    LIMIT $36 ) AS "_root.ar.root.authchains.or.authhead.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("identity_output" ), $37 ) AS "identity_output" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.ar.root.authchains.or.authhead.cf.identity_output.base"."fungible_token_amount")::text AS "fungible_token_amount", $38 AS "__typename"       ) AS "_e"      ) ) AS "identity_output" FROM  (SELECT  *  FROM "public"."transaction_identity_output"("_root.ar.root.authchains.or.authhead.base") AS "_transaction_identity_output" WHERE ($39)    LIMIT $40 ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output.base"      ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output"      ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output" ON ($41)      ) AS "_root.ar.root.authchains.or.authhead" ON ($42) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."migrations" ), $43 )  FROM  (SELECT  "_unnest_table"."migrations" AS "migrations" FROM UNNEST(array_agg("migrations" )) AS "_unnest_table"("migrations")     LIMIT $44 ) AS "_sub_query"      ) AS "migrations" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"."transaction" AS "transaction", $45 AS "__typename"       ) AS "_e"      ) ) AS "migrations" FROM  (SELECT  *  FROM "public"."authchain_migrations_view"  WHERE ((("_root.ar.root.authchains.base"."transaction_internal_id") = ("authbase_internal_id")) AND ((EXISTS  (SELECT  $46  FROM "public"."authchain_migration_transaction"("public"."authchain_migrations_view".*) AS "__be_0_authchain_migration_transaction" WHERE ((EXISTS  (SELECT  $47  FROM "public"."output" AS "__be_1_output" WHERE (((("__be_1_output"."transaction_hash") = ("__be_0_authchain_migration_transaction"."hash")) AND ($48)) AND (($49) AND ((((("public"."output_locking_bytecode_pattern"("__be_1_output".*) ) ~ (($3)::text)) AND ($50)) AND ($51)) AND ($52))))     )) AND ($53))     )) OR (EXISTS  (SELECT  $54  FROM "public"."authchain_migration_transaction"("public"."authchain_migrations_view".*) AS "__be_2_authchain_migration_transaction" WHERE ((EXISTS  (SELECT  $55  FROM "public"."input" AS "__be_3_input" WHERE (((("__be_3_input"."transaction_internal_id") = ("__be_2_authchain_migration_transaction"."internal_id")) AND ($56)) AND (($57) AND ((((("__be_3_input"."outpoint_index") = (($4)::bigint)) AND ($58)) AND (((("__be_3_input"."outpoint_transaction_hash") = ANY(($5)::bytea[])) AND ($59)) AND ($60))) AND ($61))))     )) AND ($62))     ))))     ) AS "_root.ar.root.authchains.ar.authchains.migrations.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("transaction" ), $63 ) AS "transaction" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash" AS "hash", "md5_cf189b29ac9ea2ab2029e3a8f9405135__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.block_inclusions"."block_inclusions" AS "block_inclusions", "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"."outputs" AS "outputs", $64 AS "__typename"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."authchain_migration_transaction"("_root.ar.root.authchains.ar.authchains.migrations.base") AS "_authchain_migration_transaction" WHERE ($65)    LIMIT $66 ) AS "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $67 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $68 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."token_category" AS "token_category", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode", ("md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."fungible_token_amount")::text AS "fungible_token_amount", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", $69 AS "__typename"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE (("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash") = ("transaction_hash"))     ) AS "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs" ON ($70) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $71 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $72 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"."outpoint_transaction_hash" AS "outpoint_transaction_hash", $73 AS "__typename"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."internal_id") = ("transaction_internal_id")) AND (("public"."input"."outpoint_index") = (($2)::bigint)))     ) AS "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs" ON ($74) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."block_inclusions" ), $75 )  FROM  (SELECT  "_unnest_table"."block_inclusions" AS "block_inclusions" FROM UNNEST(array_agg("block_inclusions" )) AS "_unnest_table"("block_inclusions")     LIMIT $76 ) AS "_sub_query"      ) AS "block_inclusions" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_9b01dfee23a4138dfeb058d133586a4b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.block_in
27 min < 0.1% 9 ms 189,980 chaingraph
WITH transaction_values (hash, version, locktime, size_bytes, is_coinbase) AS (
  VALUES ($1::bytea, $2::bigint, $3::bigint, $4::bigint, $5::boolean)
), output_values (output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment) AS (
  VALUES ($6::bigint, $7::bigint, $8::bytea, $9::bytea, $10, $11, $12),($13::bigint, $14::bigint, $15::bytea, $16::bytea, $17, $18, $19),($20::bigint, $21::bigint, $22::bytea, $23::bytea, $24, $25, $26)
), input_values (input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode) AS (
  VALUES ($27::bigint, $28::bigint, $29::bigint, $30::bytea, $31::bytea),($32::bigint, $33::bigint, $34::bigint, $35::bytea, $36::bytea),($37::bigint, $38::bigint, $39::bigint, $40::bytea, $41::bytea)
), node_transaction_values (node_internal_id, validated_at) AS (
  VALUES ($42::bigint, $43::timestamp)
), new_transaction (transaction_hash, transaction_internal_id) AS (
  INSERT INTO transaction (hash, version, locktime, size_bytes, is_coinbase)
    SELECT hash, version, locktime, size_bytes, is_coinbase FROM transaction_values
    ON CONFLICT ON CONSTRAINT "transaction_hash_key" DO NOTHING
    RETURNING hash AS transaction_hash, internal_id AS transaction_internal_id
), insert_outputs AS (
  INSERT INTO output (transaction_hash, output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment)
    SELECT transaction_hash, output_index, value_satoshis, locking_bytecode, token_category::bytea, fungible_token_amount::bigint, nonfungible_token_capability::enum_nonfungible_token_capability, nonfungible_token_commitment::bytea FROM output_values CROSS JOIN new_transaction
), insert_inputs AS (
  INSERT INTO input (transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode)
    SELECT transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode FROM input_values CROSS JOIN new_transaction
), new_or_existing_transaction (transaction_internal_id) AS (
  SELECT COALESCE (
    (SELECT transaction_internal_id FROM new_transaction),
    (SELECT internal_id AS transaction_internal_id FROM transaction WHERE transaction.hash = $44::bytea)
  )
)
INSERT INTO node_transaction (node_internal_id, transaction_internal_id, validated_at)
  SELECT node_internal_id, transaction_internal_id, validated_at FROM node_transaction_values CROSS JOIN new_or_existing_transaction
26 min < 0.1% 378 ms 4,204 hasura
SELECT  coalesce(json_agg("root" ), $3 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("public"."transaction"."hash") = (($2)::bytea))    LIMIT $4 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $5 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $6 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead"."authhead" AS "authhead"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.or.authhead.base"."hash" AS "hash", "_root.ar.root.authchains.or.authhead.cf.identity_output"."identity_output" AS "identity_output"       ) AS "_e"      ) ) AS "authhead" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.authchains.base"."authhead_transaction_hash") = ("hash"))    LIMIT $7 ) AS "_root.ar.root.authchains.or.authhead.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("identity_output" ), $8 ) AS "identity_output" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("_root.ar.root.authchains.or.authhead.cf.identity_output.base"."fungible_token_amount")::text AS "fungible_token_amount"       ) AS "_e"      ) ) AS "identity_output" FROM  (SELECT  *  FROM "public"."transaction_identity_output"("_root.ar.root.authchains.or.authhead.base") AS "_transaction_identity_output" WHERE ($9)    LIMIT $10 ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output.base"      ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output"      ) AS "_root.ar.root.authchains.or.authhead.cf.identity_output" ON ($11)      ) AS "_root.ar.root.authchains.or.authhead" ON ($12)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($13)      ) AS "_root"
24 min < 0.1% 788 ms 1,815 hasura
SELECT  coalesce(json_agg("root" ), $6 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("public"."transaction"."hash") = (($5)::bytea))    LIMIT $7 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $8 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $9 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length", "_root.ar.root.authchains.ar.authchains.migrations"."migrations" AS "migrations"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."migrations" ), $10 )  FROM  (SELECT  "_unnest_table"."migrations" AS "migrations" FROM UNNEST(array_agg("migrations" )) AS "_unnest_table"("migrations")     LIMIT $11 ) AS "_sub_query"      ) AS "migrations" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "migrations" FROM  (SELECT  *  FROM "public"."authchain_migrations_view"  WHERE ((("_root.ar.root.authchains.base"."transaction_internal_id") = ("authbase_internal_id")) AND (EXISTS  (SELECT  $12  FROM "public"."authchain_migration_transaction"("public"."authchain_migrations_view".*) AS "__be_0_authchain_migration_transaction" WHERE ((EXISTS  (SELECT  $13  FROM "public"."output" AS "__be_1_output" WHERE (((("__be_1_output"."transaction_hash") = ("__be_0_authchain_migration_transaction"."hash")) AND ($14)) AND (($15) AND ((((("public"."output_locking_bytecode_pattern"("__be_1_output".*) ) LIKE (($4)::text)) AND ($16)) AND ($17)) AND ($18))))     )) AND ($19))     )))     ) AS "_root.ar.root.authchains.ar.authchains.migrations.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("transaction" ), $20 ) AS "transaction" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash" AS "hash", "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."authchain_migration_transaction"("_root.ar.root.authchains.ar.authchains.migrations.base") AS "_authchain_migration_transaction" WHERE ($21)    LIMIT $22 ) AS "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $23 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $24 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash") = ("transaction_hash")) AND (("public"."output_locking_bytecode_pattern"("public"."output".*) ) LIKE (($3)::text)))     ) AS "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs" ON ($25) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $26 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $27 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"."outpoint_index")::text AS "outpoint_index"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."internal_id") = ("transaction_internal_id")) AND (("public"."input"."outpoint_index") = (($2)::bigint)))     ) AS "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs" ON ($28)      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction" ON ($29)      ) AS "_root.ar.root.authchains.ar.authchains.migrations"      ) AS "_root.ar.root.authchains.ar.authchains.migrations" ON ($30)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($31)      ) AS "_root"
18 min < 0.1% 7,680 ms 143 hasura
SELECT  coalesce(json_agg("root" ), $7 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.base"."hash" AS "hash", "_root.ar.root.authchains"."authchains" AS "authchains"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."transaction"  WHERE ((("public"."transaction"."hash") = (($5)::bytea)) AND (EXISTS  (SELECT  $8  FROM "public"."node_transaction_history" AS "__be_0_node_transaction_history" WHERE (((("__be_0_node_transaction_history"."transaction_internal_id") = ("public"."transaction"."internal_id")) AND ($9)) AND (($10) AND (((EXISTS  (SELECT  $11  FROM "public"."node" AS "__be_1_node" WHERE (((("__be_1_node"."internal_id") = ("__be_0_node_transaction_history"."node_internal_id")) AND ($12)) AND (($13) AND ((((("__be_1_node"."name") ILIKE (($6)::text)) AND ($14)) AND ($15)) AND ($16))))     )) AND ($17)) AND ($18))))     )))    LIMIT $19 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."authchains" ), $20 )  FROM  (SELECT  "_unnest_table"."authchains" AS "authchains" FROM UNNEST(array_agg("authchains" )) AS "_unnest_table"("authchains")     LIMIT $21 ) AS "_sub_query"      ) AS "authchains" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.authchains.base"."authchain_length" AS "authchain_length", "_root.ar.root.authchains.ar.authchains.migrations"."migrations" AS "migrations"       ) AS "_e"      ) ) AS "authchains" FROM  (SELECT  *  FROM "public"."authchain_view"  WHERE (("_root.base"."internal_id") = ("transaction_internal_id"))     ) AS "_root.ar.root.authchains.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."migrations" ), $22 )  FROM  (SELECT  "_unnest_table"."migrations" AS "migrations" FROM UNNEST(array_agg("migrations" )) AS "_unnest_table"("migrations")     LIMIT $23 ) AS "_sub_query"      ) AS "migrations" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"."transaction" AS "transaction"       ) AS "_e"      ) ) AS "migrations" FROM  (SELECT  *  FROM "public"."authchain_migrations_view"  WHERE ((("_root.ar.root.authchains.base"."transaction_internal_id") = ("authbase_internal_id")) AND (EXISTS  (SELECT  $24  FROM "public"."authchain_migration_transaction"("public"."authchain_migrations_view".*) AS "__be_0_authchain_migration_transaction" WHERE ((EXISTS  (SELECT  $25  FROM "public"."output" AS "__be_1_output" WHERE (((("__be_1_output"."transaction_hash") = ("__be_0_authchain_migration_transaction"."hash")) AND ($26)) AND (($27) AND ((((("public"."output_locking_bytecode_pattern"("__be_1_output".*) ) LIKE (($4)::text)) AND ($28)) AND ($29)) AND ($30))))     )) AND ($31))     )))     ) AS "_root.ar.root.authchains.ar.authchains.migrations.base" LEFT OUTER JOIN LATERAL (SELECT  coalesce(json_agg("transaction" ), $32 ) AS "transaction" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash" AS "hash", "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"."outputs" AS "outputs"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."authchain_migration_transaction"("_root.ar.root.authchains.ar.authchains.migrations.base") AS "_authchain_migration_transaction" WHERE ($33)    LIMIT $34 ) AS "md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $35 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $36 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."output_index")::text AS "output_index", "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."hash") = ("transaction_hash")) AND (("public"."output_locking_bytecode_pattern"("public"."output".*) ) LIKE (($3)::text)))     ) AS "md5_422ccf887600486a3c5ada21267a7754__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs.base"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs"      ) AS "md5_b3073ff054c345a9d0e8a6c6cec47958__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.outputs" ON ($37) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $38 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $39 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  ("md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"."outpoint_index")::text AS "outpoint_index"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE ((("md5_18c154247a64833a35eed3734150d99b__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.base"."internal_id") = ("transaction_internal_id")) AND (("public"."input"."outpoint_index") = (($2)::bigint)))     ) AS "md5_c57299b49eed7577ccc55c54ffaf4e43__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs.base"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs"      ) AS "md5_3801b81ffaaf85feedad8ee273a3ee8a__root.ar.root.authchains.ar.authchains.migrations.cf.transaction.ar.transaction.inputs" ON ($40)      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction"      ) AS "md5_503a3bf0689befcaab27bd8f8f887488__root.ar.root.authchains.ar.authchains.migrations.cf.transaction" ON ($41)      ) AS "_root.ar.root.authchains.ar.authchains.migrations"      ) AS "_root.ar.root.authchains.ar.authchains.migrations" ON ($42)      ) AS "_root.ar.root.authchains"      ) AS "_root.ar.root.authchains" ON ($43)      ) AS "_root"
18 min < 0.1% 3,822 ms 280 hasura
SELECT  coalesce(json_agg("root" ), $4 ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.accepted_blocks"."accepted_blocks" AS "accepted_blocks", "_root.ar.root.unconfirmed_transactions"."unconfirmed_transactions" AS "unconfirmed_transactions", $5 AS "__typename"       ) AS "_e"      ) ) AS "root" FROM  (SELECT  *  FROM "public"."node"  WHERE (("public"."node"."name") ~ (($3)::text))    LIMIT $6 ) AS "_root.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."accepted_blocks" ORDER BY "ob_col_1" DESC NULLS FIRST), $7 )  FROM  (SELECT  "_unnest_table"."accepted_blocks" AS "accepted_blocks", "_unnest_table"."ob_col_1" AS "ob_col_1" FROM UNNEST(array_agg("accepted_blocks" ), array_agg("root.ar.root.accepted_blocks.or.block.pg.height" )) AS "_unnest_table"("accepted_blocks", "ob_col_1")    ORDER BY "ob_col_1" DESC NULLS FIRST LIMIT $8 ) AS "_sub_query"      ) AS "accepted_blocks" FROM  (SELECT  "_root.ar.root.accepted_blocks.or.block"."root.ar.root.accepted_blocks.or.block.pg.height" AS "root.ar.root.accepted_blocks.or.block.pg.height", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.accepted_blocks.or.block"."block" AS "block", $9 AS "__typename"       ) AS "_e"      ) ) AS "accepted_blocks" FROM  (SELECT  *  FROM "public"."node_block"  WHERE (("_root.base"."internal_id") = ("node_internal_id"))     ) AS "_root.ar.root.accepted_blocks.base" LEFT OUTER JOIN LATERAL (SELECT  "_root.ar.root.accepted_blocks.or.block.base"."height" AS "root.ar.root.accepted_blocks.or.block.pg.height", row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.accepted_blocks.or.block.base"."hash" AS "hash", ("_root.ar.root.accepted_blocks.or.block.base"."timestamp")::text AS "timestamp", ("_root.ar.root.accepted_blocks.or.block.base"."height")::text AS "height", $10 AS "__typename"       ) AS "_e"      ) ) AS "block" FROM  (SELECT  *  FROM "public"."block"  WHERE (("_root.ar.root.accepted_blocks.base"."block_internal_id") = ("internal_id"))    LIMIT $11 ) AS "_root.ar.root.accepted_blocks.or.block.base"      ) AS "_root.ar.root.accepted_blocks.or.block" ON ($12)    ORDER BY "root.ar.root.accepted_blocks.or.block.pg.height" DESC NULLS FIRST LIMIT $13 ) AS "_root.ar.root.accepted_blocks"      ) AS "_root.ar.root.accepted_blocks" ON ($14) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."unconfirmed_transactions" ORDER BY "ob_col_1" DESC NULLS FIRST), $15 )  FROM  (SELECT  "_unnest_table"."unconfirmed_transactions" AS "unconfirmed_transactions", "_unnest_table"."ob_col_1" AS "ob_col_1" FROM UNNEST(array_agg("unconfirmed_transactions" ), array_agg("root.ar.root.unconfirmed_transactions.pg.validated_at" )) AS "_unnest_table"("unconfirmed_transactions", "ob_col_1")    ORDER BY "ob_col_1" DESC NULLS FIRST LIMIT $16 ) AS "_sub_query"      ) AS "unconfirmed_transactions" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.unconfirmed_transactions.or.transaction"."transaction" AS "transaction", $17 AS "__typename"       ) AS "_e"      ) ) AS "unconfirmed_transactions", "_root.ar.root.unconfirmed_transactions.base"."validated_at" AS "root.ar.root.unconfirmed_transactions.pg.validated_at" FROM  (SELECT  *  FROM "public"."node_transaction"  WHERE ((("_root.base"."internal_id") = ("node_internal_id")) AND (EXISTS  (SELECT  $18  FROM "public"."transaction" AS "__be_0_transaction" WHERE (((("__be_0_transaction"."internal_id") = ("public"."node_transaction"."transaction_internal_id")) AND ($19)) AND (($20) AND ((((("__be_0_transaction"."hash") = (($2)::bytea)) AND ($21)) AND ($22)) AND ($23))))     )))   ORDER BY "validated_at" DESC NULLS FIRST  ) AS "_root.ar.root.unconfirmed_transactions.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "_root.ar.root.unconfirmed_transactions.or.transaction.base"."hash" AS "hash", ("public"."transaction_input_value_satoshis"("_root.ar.root.unconfirmed_transactions.or.transaction.base") )::text AS "input_value_satoshis", ("public"."transaction_output_value_satoshis"("_root.ar.root.unconfirmed_transactions.or.transaction.base") )::text AS "output_value_satoshis", "_root.ar.root.unconfirmed_transactions.or.transaction.base"."is_coinbase" AS "is_coinbase", "md5_49487847c71397880ad861be633472aa__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.block_inclusions"."block_inclusions" AS "block_inclusions", "md5_b6cc12c09542ad52ba9b87baa9b812ef__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs"."inputs" AS "inputs", "md5_408769f88a061e776e7caeed495b93f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs"."outputs" AS "outputs", $24 AS "__typename"       ) AS "_e"      ) ) AS "transaction" FROM  (SELECT  *  FROM "public"."transaction"  WHERE (("_root.ar.root.unconfirmed_transactions.base"."transaction_internal_id") = ("internal_id"))    LIMIT $25 ) AS "_root.ar.root.unconfirmed_transactions.or.transaction.base" LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."outputs" ), $26 )  FROM  (SELECT  "_unnest_table"."outputs" AS "outputs" FROM UNNEST(array_agg("outputs" )) AS "_unnest_table"("outputs")     LIMIT $27 ) AS "_sub_query"      ) AS "outputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."token_category" AS "token_category", ("md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."fungible_token_amount")::text AS "fungible_token_amount", "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."locking_bytecode" AS "locking_bytecode", ("md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"."value_satoshis")::text AS "value_satoshis", $28 AS "__typename"       ) AS "_e"      ) ) AS "outputs" FROM  (SELECT  *  FROM "public"."output"  WHERE (("_root.ar.root.unconfirmed_transactions.or.transaction.base"."hash") = ("transaction_hash"))     ) AS "md5_892124844302a7d0ff4668f281debdc2__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs.base"      ) AS "md5_408769f88a061e776e7caeed495b93f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs"      ) AS "md5_408769f88a061e776e7caeed495b93f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.outputs" ON ($29) LEFT OUTER JOIN LATERAL (SELECT  (SELECT  coalesce(json_agg("_sub_query"."inputs" ), $30 )  FROM  (SELECT  "_unnest_table"."inputs" AS "inputs" FROM UNNEST(array_agg("inputs" )) AS "_unnest_table"("inputs")     LIMIT $31 ) AS "_sub_query"      ) AS "inputs" FROM  (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base"."unlocking_bytecode" AS "unlocking_bytecode", ("public"."input_value_satoshis"("md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base") )::text AS "value_satoshis", "md5_449b6821e778500d7dd8178a97963065__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint"."outpoint" AS "outpoint", $32 AS "__typename"       ) AS "_e"      ) ) AS "inputs" FROM  (SELECT  *  FROM "public"."input"  WHERE (("_root.ar.root.unconfirmed_transactions.or.transaction.base"."internal_id") = ("transaction_internal_id"))     ) AS "md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base" LEFT OUTER JOIN LATERAL (SELECT  row_to_json((SELECT  "_e"  FROM  (SELECT  "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."token_category" AS "token_category", ("md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."fungible_token_amount")::text AS "fungible_token_amount", "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."nonfungible_token_commitment" AS "nonfungible_token_commitment", "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."nonfungible_token_capability" AS "nonfungible_token_capability", "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."locking_bytecode" AS "locking_bytecode", ("md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"."value_satoshis")::text AS "value_satoshis", $33 AS "__typename"       ) AS "_e"      ) ) AS "outpoint" FROM  (SELECT  *  FROM "public"."output"  WHERE ((("md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base"."outpoint_index") = ("output_index")) AND (("md5_e182d29c2b2d2f240b3e67ae68696469__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.base"."outpoint_transaction_hash") = ("transaction_hash")))    LIMIT $34 ) AS "md5_8590517439f1540cd51f86ae22eb97f8__root.ar.root.unconfirmed_transactions.or.transaction.ar.transaction.inputs.or.outpoint.base"      ) AS "md5_449b6821e778500d7dd8178a97963065__root.ar.root.unconfirmed_transactions.or.transaction.a
17 min < 0.1% 7 ms 149,768 chaingraph
WITH transaction_values (hash, version, locktime, size_bytes, is_coinbase) AS (
  VALUES ($1::bytea, $2::bigint, $3::bigint, $4::bigint, $5::boolean)
), output_values (output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment) AS (
  VALUES ($6::bigint, $7::bigint, $8::bytea, $9::bytea, $10, $11, $12),($13::bigint, $14::bigint, $15::bytea, $16::bytea, $17, $18, $19)
), input_values (input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode) AS (
  VALUES ($20::bigint, $21::bigint, $22::bigint, $23::bytea, $24::bytea),($25::bigint, $26::bigint, $27::bigint, $28::bytea, $29::bytea)
), node_transaction_values (node_internal_id, validated_at) AS (
  VALUES ($30::bigint, $31::timestamp)
), new_transaction (transaction_hash, transaction_internal_id) AS (
  INSERT INTO transaction (hash, version, locktime, size_bytes, is_coinbase)
    SELECT hash, version, locktime, size_bytes, is_coinbase FROM transaction_values
    ON CONFLICT ON CONSTRAINT "transaction_hash_key" DO NOTHING
    RETURNING hash AS transaction_hash, internal_id AS transaction_internal_id
), insert_outputs AS (
  INSERT INTO output (transaction_hash, output_index, value_satoshis, locking_bytecode, token_category, fungible_token_amount, nonfungible_token_capability, nonfungible_token_commitment)
    SELECT transaction_hash, output_index, value_satoshis, locking_bytecode, token_category::bytea, fungible_token_amount::bigint, nonfungible_token_capability::enum_nonfungible_token_capability, nonfungible_token_commitment::bytea FROM output_values CROSS JOIN new_transaction
), insert_inputs AS (
  INSERT INTO input (transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode)
    SELECT transaction_internal_id, input_index, outpoint_index, sequence_number, outpoint_transaction_hash, unlocking_bytecode FROM input_values CROSS JOIN new_transaction
), new_or_existing_transaction (transaction_internal_id) AS (
  SELECT COALESCE (
    (SELECT transaction_internal_id FROM new_transaction),
    (SELECT internal_id AS transaction_internal_id FROM transaction WHERE transaction.hash = $32::bytea)
  )
)
INSERT INTO node_transaction (node_internal_id, transaction_internal_id, validated_at)
  SELECT node_internal_id, transaction_internal_id, validated_at FROM node_transaction_values CROSS JOIN new_or_existing_transaction
16 min < 0.1% 0 ms 340,800,080 hasura
SELECT COUNT(*) from input WHERE input.transaction_internal_id = transaction_row.internal_id
16 min < 0.1% 32,627 ms 29 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($69, $70::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($71, $72, $73,
      $74::bytea,
      $75::bytea,
      $76::bytea,
      $77::bigint, $78::bigint, $79::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $80::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
16 min < 0.1% 24,256 ms 39 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($37, $38::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($39, $40, $41,
      $42::bytea,
      $43::bytea,
      $44::bytea,
      $45::bigint, $46::bigint, $47::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $48::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
16 min < 0.1% 47,080 ms 20 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($59, $60::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($61, $62, $63,
      $64::bytea,
      $65::bytea,
      $66::bytea,
      $67::bigint, $68::bigint, $69::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $70::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
16 min < 0.1% 28,409 ms 33 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($23, $24::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($25, $26, $27,
      $28::bytea,
      $29::bytea,
      $30::bytea,
      $31::bigint, $32::bigint, $33::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $34::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
16 min < 0.1% 84,981 ms 11 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint),($113::bytea, $114::bigint),($115::bytea, $116::bigint),($117::bytea, $118::bigint),($119::bytea, $120::bigint),($121::bytea, $122::bigint),($123::bytea, $124::bigint),($125::bytea, $126::bigint),($127::bytea, $128::bigint),($129::bytea, $130::bigint),($131::bytea, $132::bigint),($133::bytea, $134::bigint),($135::bytea, $136::bigint),($137::bytea, $138::bigint),($139::bytea, $140::bigint),($141::bytea, $142::bigint),($143::bytea, $144::bigint),($145::bytea, $146::bigint),($147::bytea, $148::bigint),($149::bytea, $150::bigint),($151::bytea, $152::bigint),($153::bytea, $154::bigint),($155::bytea, $156::bigint),($157::bytea, $158::bigint),($159::bytea, $160::bigint),($161::bytea, $162::bigint),($163::bytea, $164::bigint),($165::bytea, $166::bigint),($167::bytea, $168::bigint),($169::bytea, $170::bigint),($171::bytea, $172::bigint),($173::bytea, $174::bigint),($175::bytea, $176::bigint),($177::bytea, $178::bigint),($179::bytea, $180::bigint),($181::bytea, $182::bigint),($183::bytea, $184::bigint),($185::bytea, $186::bigint),($187::bytea, $188::bigint),($189::bytea, $190::bigint),($191::bytea, $192::bigint),($193::bytea, $194::bigint),($195::bytea, $196::bigint),($197::bytea, $198::bigint),($199::bytea, $200::bigint),($201::bytea, $202::bigint),($203::bytea, $204::bigint),($205::bytea, $206::bigint),($207::bytea, $208::bigint),($209::bytea, $210::bigint),($211::bytea, $212::bigint),($213::bytea, $214::bigint),($215::bytea, $216::bigint),($217::bytea, $218::bigint),($219::bytea, $220::bigint),($221::bytea, $222::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($223, $224::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($225, $226, $227,
      $228::bytea,
      $229::bytea,
      $230::bytea,
      $231::bigint, $232::bigint, $233::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $234::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
16 min < 0.1% 38,870 ms 24 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($79, $80::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($81, $82, $83,
      $84::bytea,
      $85::bytea,
      $86::bytea,
      $87::bigint, $88::bigint, $89::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $90::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 18,226 ms 51 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($17, $18::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($19, $20, $21,
      $22::bytea,
      $23::bytea,
      $24::bytea,
      $25::bigint, $26::bigint, $27::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $28::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 33,125 ms 28 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($65, $66::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($67, $68, $69,
      $70::bytea,
      $71::bytea,
      $72::bytea,
      $73::bigint, $74::bigint, $75::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $76::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 1,759 ms 527 chaingraph
WITH query_stats AS ( SELECT LEFT(query, $1) AS query, queryid AS query_hash, rolname AS user, ((total_plan_time + total_exec_time) / $2 / $3) AS total_minutes, ((total_plan_time + total_exec_time) / calls) AS average_time, calls FROM pg_stat_statements INNER JOIN pg_database ON pg_database.oid = pg_stat_statements.dbid INNER JOIN pg_roles ON pg_roles.oid = pg_stat_statements.userid WHERE calls > $4 AND pg_database.datname = current_database() ) SELECT query, query AS explainable_query, query_hash, query_stats.user, total_minutes, average_time, calls, total_minutes * $5 / (SELECT SUM(total_minutes) FROM query_stats) AS total_percent, (SELECT SUM(total_minutes) FROM query_stats) AS all_queries_total_minutes FROM query_stats ORDER BY "total_minutes" DESC LIMIT $6 /*pghero*/
15 min < 0.1% 48,584 ms 19 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($113, $114::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($115, $116, $117,
      $118::bytea,
      $119::bytea,
      $120::bytea,
      $121::bigint, $122::bigint, $123::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $124::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 38,400 ms 24 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($105, $106::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($107, $108, $109,
      $110::bytea,
      $111::bytea,
      $112::bytea,
      $113::bigint, $114::bigint, $115::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $116::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 459,969 ms 2 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint),($113::bytea, $114::bigint),($115::bytea, $116::bigint),($117::bytea, $118::bigint),($119::bytea, $120::bigint),($121::bytea, $122::bigint),($123::bytea, $124::bigint),($125::bytea, $126::bigint),($127::bytea, $128::bigint),($129::bytea, $130::bigint),($131::bytea, $132::bigint),($133::bytea, $134::bigint),($135::bytea, $136::bigint),($137::bytea, $138::bigint),($139::bytea, $140::bigint),($141::bytea, $142::bigint),($143::bytea, $144::bigint),($145::bytea, $146::bigint),($147::bytea, $148::bigint),($149::bytea, $150::bigint),($151::bytea, $152::bigint),($153::bytea, $154::bigint),($155::bytea, $156::bigint),($157::bytea, $158::bigint),($159::bytea, $160::bigint),($161::bytea, $162::bigint),($163::bytea, $164::bigint),($165::bytea, $166::bigint),($167::bytea, $168::bigint),($169::bytea, $170::bigint),($171::bytea, $172::bigint),($173::bytea, $174::bigint),($175::bytea, $176::bigint),($177::bytea, $178::bigint),($179::bytea, $180::bigint),($181::bytea, $182::bigint),($183::bytea, $184::bigint),($185::bytea, $186::bigint),($187::bytea, $188::bigint),($189::bytea, $190::bigint),($191::bytea, $192::bigint),($193::bytea, $194::bigint),($195::bytea, $196::bigint),($197::bytea, $198::bigint),($199::bytea, $200::bigint),($201::bytea, $202::bigint),($203::bytea, $204::bigint),($205::bytea, $206::bigint),($207::bytea, $208::bigint),($209::bytea, $210::bigint),($211::bytea, $212::bigint),($213::bytea, $214::bigint),($215::bytea, $216::bigint),($217::bytea, $218::bigint),($219::bytea, $220::bigint),($221::bytea, $222::bigint),($223::bytea, $224::bigint),($225::bytea, $226::bigint),($227::bytea, $228::bigint),($229::bytea, $230::bigint),($231::bytea, $232::bigint),($233::bytea, $234::bigint),($235::bytea, $236::bigint),($237::bytea, $238::bigint),($239::bytea, $240::bigint),($241::bytea, $242::bigint),($243::bytea, $244::bigint),($245::bytea, $246::bigint),($247::bytea, $248::bigint),($249::bytea, $250::bigint),($251::bytea, $252::bigint),($253::bytea, $254::bigint),($255::bytea, $256::bigint),($257::bytea, $258::bigint),($259::bytea, $260::bigint),($261::bytea, $262::bigint),($263::bytea, $264::bigint),($265::bytea, $266::bigint),($267::bytea, $268::bigint),($269::bytea, $270::bigint),($271::bytea, $272::bigint),($273::bytea, $274::bigint),($275::bytea, $276::bigint),($277::bytea, $278::bigint),($279::bytea, $280::bigint),($281::bytea, $282::bigint),($283::bytea, $284::bigint),($285::bytea, $286::bigint),($287::bytea, $288::bigint),($289::bytea, $290::bigint),($291::bytea, $292::bigint),($293::bytea, $294::bigint),($295::bytea, $296::bigint),($297::bytea, $298::bigint),($299::bytea, $300::bigint),($301::bytea, $302::bigint),($303::bytea, $304::bigint),($305::bytea, $306::bigint),($307::bytea, $308::bigint),($309::bytea, $310::bigint),($311::bytea, $312::bigint),($313::bytea, $314::bigint),($315::bytea, $316::bigint),($317::bytea, $318::bigint),($319::bytea, $320::bigint),($321::bytea, $322::bigint),($323::bytea, $324::bigint),($325::bytea, $326::bigint),($327::bytea, $328::bigint),($329::bytea, $330::bigint),($331::bytea, $332::bigint),($333::bytea, $334::bigint),($335::bytea, $336::bigint),($337::bytea, $338::bigint),($339::bytea, $340::bigint),($341::bytea, $342::bigint),($343::bytea, $344::bigint),($345::bytea, $346::bigint),($347::bytea, $348::bigint),($349::bytea, $350::bigint),($351::bytea, $352::bigint),($353::bytea, $354::bigint),($355::bytea, $356::bigint),($357::bytea, $358::bigint),($359::bytea, $360::bigint),($361::bytea, $362::bigint),($363::bytea, $364::bigint),($365::bytea, $366::bigint),($367::bytea, $368::bigint),($369::bytea, $370::bigint),($371::bytea, $372::bigint),($373::bytea, $374::bigint),($375::bytea, $376::bigint),($377::bytea, $378::bigint),($379::bytea, $380::bigint),($381::bytea, $382::bigint),($383::bytea, $384::bigint),($385::bytea, $386::bigint),($387::bytea, $388::bigint),($389::bytea, $390::bigint),($391::bytea, $392::bigint),($393::bytea, $394::bigint),($395::bytea, $396::bigint),($397::bytea, $398::bigint),($399::bytea, $400::bigint),($401::bytea, $402::bigint),($403::bytea, $404::bigint),($405::bytea, $406::bigint),($407::bytea, $408::bigint),($409::bytea, $410::bigint),($411::bytea, $412::bigint),($413::bytea, $414::bigint),($415::bytea, $416::bigint),($417::bytea, $418::bigint),($419::bytea, $420::bigint),($421::bytea, $422::bigint),($423::bytea, $424::bigint),($425::bytea, $426::bigint),($427::bytea, $428::bigint),($429::bytea, $430::bigint),($431::bytea, $432::bigint),($433::bytea, $434::bigint),($435::bytea, $436::bigint),($437::bytea, $438::bigint),($439::bytea, $440::bigint),($441::bytea, $442::bigint),($443::bytea, $444::bigint),($445::bytea, $446::bigint),($447::bytea, $448::bigint),($449::bytea, $450::bigint),($451::bytea, $452::bigint),($453::bytea, $454::bigint),($455::bytea, $456::bigint),($457::bytea, $458::bigint),($459::bytea, $460::bigint),($461::bytea, $462::bigint),($463::bytea, $464::bigint),($465::bytea, $466::bigint),($467::bytea, $468::bigint),($469::bytea, $470::bigint),($471::bytea, $472::bigint),($473::bytea, $474::bigint),($475::bytea, $476::bigint),($477::bytea, $478::bigint),($479::bytea, $480::bigint),($481::bytea, $482::bigint),($483::bytea, $484::bigint),($485::bytea, $486::bigint),($487::bytea, $488::bigint),($489::bytea, $490::bigint),($491::bytea, $492::bigint),($493::bytea, $494::bigint),($495::bytea, $496::bigint),($497::bytea, $498::bigint),($499::bytea, $500::bigint),($501::bytea, $502::bigint),($503::bytea, $504::bigint),($505::bytea, $506::bigint),($507::bytea, $508::bigint),($509::bytea, $510::bigint),($511::bytea, $512::bigint),($513::bytea, $514::bigint),($515::bytea, $516::bigint),($517::bytea, $518::bigint),($519::bytea, $520::bigint),($521::bytea, $522::bigint),($523::bytea, $524::bigint),($525::bytea, $526::bigint),($527::bytea, $528::bigint),($529::bytea, $530::bigint),($531::bytea, $532::bigint),($533::bytea, $534::bigint),($535::bytea, $536::bigint),($537::bytea, $538::bigint),($539::bytea, $540::bigint),($541::bytea, $542::bigint),($543::bytea, $544::bigint),($545::bytea, $546::bigint),($547::bytea, $548::bigint),($549::bytea, $550::bigint),($551::bytea, $552::bigint),($553::bytea, $554::bigint),($555::bytea, $556::bigint),($557::bytea, $558::bigint),($559::bytea, $560::bigint),($561::bytea, $562::bigint),($563::bytea, $564::bigint),($565::bytea, $566::bigint),($567::bytea, $568::bigint),($569::bytea, $570::bigint),($571::bytea, $572::bigint),($573::bytea, $574::bigint),($575::bytea, $576::bigint),($577::bytea, $578::bigint),($579::bytea, $580::bigint),($581::bytea, $582::bigint),($583::bytea, $584::bigint),($585::bytea, $586::bigint),($587::bytea, $588::bigint),($589::bytea, $590::bigint),($591::bytea, $592::bigint),($593::bytea, $594::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($595, $596::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($597, $598, $599,
      $600::bytea,
      $601::bytea,
      $602::bytea,
      $603::bigint, $604::bigint, $605::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $606::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 45,974 ms 20 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($83, $84::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($85, $86, $87,
      $88::bytea,
      $89::bytea,
      $90::bytea,
      $91::bigint, $92::bigint, $93::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $94::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 28,673 ms 32 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($47, $48::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($49, $50, $51,
      $52::bytea,
      $53::bytea,
      $54::bytea,
      $55::bigint, $56::bigint, $57::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $58::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 20,310 ms 45 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($39, $40::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($41, $42, $43,
      $44::bytea,
      $45::bytea,
      $46::bytea,
      $47::bigint, $48::bigint, $49::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $50::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 20,669 ms 44 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($27, $28::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($29, $30, $31,
      $32::bytea,
      $33::bytea,
      $34::bytea,
      $35::bigint, $36::bigint, $37::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $38::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 12,103 ms 75 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($11, $12::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($13, $14, $15,
      $16::bytea,
      $17::bytea,
      $18::bytea,
      $19::bigint, $20::bigint, $21::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $22::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 47,745 ms 19 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($101, $102::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($103, $104, $105,
      $106::bytea,
      $107::bytea,
      $108::bytea,
      $109::bigint, $110::bigint, $111::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $112::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 74,920 ms 12 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint),($113::bytea, $114::bigint),($115::bytea, $116::bigint),($117::bytea, $118::bigint),($119::bytea, $120::bigint),($121::bytea, $122::bigint),($123::bytea, $124::bigint),($125::bytea, $126::bigint),($127::bytea, $128::bigint),($129::bytea, $130::bigint),($131::bytea, $132::bigint),($133::bytea, $134::bigint),($135::bytea, $136::bigint),($137::bytea, $138::bigint),($139::bytea, $140::bigint),($141::bytea, $142::bigint),($143::bytea, $144::bigint),($145::bytea, $146::bigint),($147::bytea, $148::bigint),($149::bytea, $150::bigint),($151::bytea, $152::bigint),($153::bytea, $154::bigint),($155::bytea, $156::bigint),($157::bytea, $158::bigint),($159::bytea, $160::bigint),($161::bytea, $162::bigint),($163::bytea, $164::bigint),($165::bytea, $166::bigint),($167::bytea, $168::bigint),($169::bytea, $170::bigint),($171::bytea, $172::bigint),($173::bytea, $174::bigint),($175::bytea, $176::bigint),($177::bytea, $178::bigint),($179::bytea, $180::bigint),($181::bytea, $182::bigint),($183::bytea, $184::bigint),($185::bytea, $186::bigint),($187::bytea, $188::bigint),($189::bytea, $190::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($191, $192::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($193, $194, $195,
      $196::bytea,
      $197::bytea,
      $198::bytea,
      $199::bigint, $200::bigint, $201::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $202::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING
15 min < 0.1% 81,243 ms 11 chaingraph
WITH transactions_in_block (hash, transaction_index) AS (
  VALUES ($1::bytea, $2::bigint),($3::bytea, $4::bigint),($5::bytea, $6::bigint),($7::bytea, $8::bigint),($9::bytea, $10::bigint),($11::bytea, $12::bigint),($13::bytea, $14::bigint),($15::bytea, $16::bigint),($17::bytea, $18::bigint),($19::bytea, $20::bigint),($21::bytea, $22::bigint),($23::bytea, $24::bigint),($25::bytea, $26::bigint),($27::bytea, $28::bigint),($29::bytea, $30::bigint),($31::bytea, $32::bigint),($33::bytea, $34::bigint),($35::bytea, $36::bigint),($37::bytea, $38::bigint),($39::bytea, $40::bigint),($41::bytea, $42::bigint),($43::bytea, $44::bigint),($45::bytea, $46::bigint),($47::bytea, $48::bigint),($49::bytea, $50::bigint),($51::bytea, $52::bigint),($53::bytea, $54::bigint),($55::bytea, $56::bigint),($57::bytea, $58::bigint),($59::bytea, $60::bigint),($61::bytea, $62::bigint),($63::bytea, $64::bigint),($65::bytea, $66::bigint),($67::bytea, $68::bigint),($69::bytea, $70::bigint),($71::bytea, $72::bigint),($73::bytea, $74::bigint),($75::bytea, $76::bigint),($77::bytea, $78::bigint),($79::bytea, $80::bigint),($81::bytea, $82::bigint),($83::bytea, $84::bigint),($85::bytea, $86::bigint),($87::bytea, $88::bigint),($89::bytea, $90::bigint),($91::bytea, $92::bigint),($93::bytea, $94::bigint),($95::bytea, $96::bigint),($97::bytea, $98::bigint),($99::bytea, $100::bigint),($101::bytea, $102::bigint),($103::bytea, $104::bigint),($105::bytea, $106::bigint),($107::bytea, $108::bigint),($109::bytea, $110::bigint),($111::bytea, $112::bigint),($113::bytea, $114::bigint),($115::bytea, $116::bigint),($117::bytea, $118::bigint),($119::bytea, $120::bigint),($121::bytea, $122::bigint),($123::bytea, $124::bigint),($125::bytea, $126::bigint),($127::bytea, $128::bigint),($129::bytea, $130::bigint),($131::bytea, $132::bigint),($133::bytea, $134::bigint),($135::bytea, $136::bigint),($137::bytea, $138::bigint),($139::bytea, $140::bigint),($141::bytea, $142::bigint),($143::bytea, $144::bigint),($145::bytea, $146::bigint),($147::bytea, $148::bigint),($149::bytea, $150::bigint),($151::bytea, $152::bigint),($153::bytea, $154::bigint),($155::bytea, $156::bigint),($157::bytea, $158::bigint),($159::bytea, $160::bigint),($161::bytea, $162::bigint),($163::bytea, $164::bigint),($165::bytea, $166::bigint),($167::bytea, $168::bigint),($169::bytea, $170::bigint),($171::bytea, $172::bigint),($173::bytea, $174::bigint),($175::bytea, $176::bigint),($177::bytea, $178::bigint),($179::bytea, $180::bigint),($181::bytea, $182::bigint)
),
accepting_nodes (node_internal_id, accepted_at) AS (
  VALUES ($183, $184::timestamp)
),
joined_transactions (internal_id, transaction_index) AS (
  SELECT db.internal_id, val.transaction_index
    FROM transaction db INNER JOIN transactions_in_block val ON val.hash = db.hash
),
inserted_block (internal_id) AS (
  INSERT INTO block (height, version, timestamp, hash, previous_block_hash, merkle_root, bits, nonce, size_bytes)
    VALUES ($185, $186, $187,
      $188::bytea,
      $189::bytea,
      $190::bytea,
      $191::bigint, $192::bigint, $193::bigint)
  ON CONFLICT ON CONSTRAINT "block_hash_key" DO NOTHING
  RETURNING internal_id
),
inserted_block_transactions AS (
  INSERT INTO block_transaction (block_internal_id, transaction_internal_id, transaction_index)
    SELECT blk.internal_id, tx.internal_id, tx.transaction_index
      FROM inserted_block blk CROSS JOIN joined_transactions tx
),
new_or_existing_block (internal_id) AS (
  SELECT COALESCE (
    (SELECT internal_id FROM inserted_block),
    (SELECT internal_id FROM block WHERE block.hash = $194::bytea)
  )
)
INSERT INTO node_block (node_internal_id, block_internal_id, accepted_at)
  SELECT node.node_internal_id, blk.internal_id, node.accepted_at
    FROM new_or_existing_block blk CROSS JOIN accepting_nodes node
  ON CONFLICT ON CONSTRAINT "node_block_pkey" DO NOTHING