Estimate query execution time error

Hi, folks!

I’m intermittently getting errors of the form:

ActiveRecord::ActiveRecordError: Response code: 500: Code: 160, e.displayText() = DB::Exception: Estimated query execution time (140.36344519736843 seconds) is too long. Maximum: 50. Estimated rows to process: 44928: While executing MergeTreeThread: While executing CreatingSetsTransform (version 20.8.11.17 (official build))

Query:


query GetAddresses($network: BitcoinNetwork!, $addresses: [String!], $inboundDepth: Int!, $outboundDepth: Int!, $limit: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  bitcoin(network: $network) {
    inbound: coinpath(
      initialAddress: {in: $addresses}
      depth: {lteq: $inboundDepth}
      options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}
      date: {since: $from, till: $till}
    ) {
      sender {
        address
        annotation
        __typename
      }
      receiver {
        address
        annotation
        __typename
      }
      transactions {
        amount
        height
        timestamp
        txHash
        txValue
        __typename
      }
      amount
      depth
      count
      __typename
    }
    outbound: coinpath(
      initialAddress: {in: $addresses}
      depth: {lteq: $outboundDepth}
      options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}
      date: {since: $from, till: $till}
    ) {
      sender {
        address
        annotation
        __typename
      }
      receiver {
        address
        annotation
        __typename
      }
      transactions {
        amount
        height
        timestamp
        txHash
        txValue
        __typename
      }
      amount
      depth
      count
      __typename
    }
    __typename
  }
}

Variables:

{
  "addresses": [
    "164fawNZVwsR5SamAJypvCMtkMx4Xv1B3f"
  ],
  "inboundDepth": 1,
  "outboundDepth": 4,
  "limit": 9999,
  "network": "bitcoin",
  "from": null,
  "till": null
}

Am I doing anything wrong here?

Thanks for reading! :v:

Reduce the limit and it should work.
Here is the updated query: