Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row count estimate #736

Merged
merged 4 commits into from
Jan 6, 2022
Merged

Conversation

fishmonger45
Copy link
Contributor

@fishmonger45 fishmonger45 commented Jan 5, 2022

Adds a row count estimate to the metadata plugin for query service. Although it uses a custom gql type rather than a generic json object.
Implements: #734
Example:

query {
  _metadata {
    rowCountEstimate {
      table,
      estimate
    }
  }
}
{
  "data": {
    "_metadata": {
      "rowCountEstimate": [
        {
          "table": "starter_entities",
          "estimate": 195220
        },
        {
          "table": "_metadata",
          "estimate": 9
        }
      ]
    }
  }
}


return metadata;
}

export const GetMetadataPlugin = makeExtendSchemaPlugin((build, options) => {
const schemaName = options.pgSchemas;
const [schemaName] = options.pgSchemas;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There wasn't any error before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. It gets cast to string fine but it was really [string]. Can't trust the types with a whole lot of any being used here, but the plugin needs it so no avoiding.

@ianhe8x ianhe8x marked this pull request as ready for review January 6, 2022 21:39
@fishmonger45
Copy link
Contributor Author

Seems my chaintypes error pull that has been merged is causing problems with the CI. I'll fix this by either removing the process exit and moving it to the validate or mocking process exit in that test.

@ianhe8x
Copy link
Collaborator

ianhe8x commented Jan 6, 2022

@wqsz7xn I can merge this one and you fix it in another PR.

@ianhe8x ianhe8x merged commit 2238da5 into subquery:main Jan 6, 2022
bz888 pushed a commit that referenced this pull request Jun 3, 2022
* basic string encoded estimate

* add row count estimate to metadata plugin

* fix build

* decompose schemaName to properly match type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants