sqlstatsutil

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildStmtMetadataJSON

func BuildStmtMetadataJSON(statistics *roachpb.CollectedStatementStatistics) (json.JSON, error)

BuildStmtMetadataJSON returns a json.JSON object for the metadata section of the roachpb.CollectedStatementStatistics. JSON Schema for statement metadata:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "system.statement_statistics.metadata",
  "type": "object",
  "properties": {
    "stmtTyp":              { "type": "string" },
    "query":                { "type": "string" },
    "db":                   { "type": "string" },
    "distsql":              { "type": "boolean" },
    "failed":               { "type": "boolean" },
    "implicitTxn":          { "type": "boolean" },
    "vec":                  { "type": "boolean" },
    "fullScan":             { "type": "boolean" },
  }
}

func BuildStmtStatisticsJSON

func BuildStmtStatisticsJSON(statistics *roachpb.StatementStatistics) (json.JSON, error)

BuildStmtStatisticsJSON encodes the statistics section a given roachpb.CollectedStatementStatistics into a json.JSON object.

JSON Schema for stats portion:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "system.statement_statistics.statistics",
  "type": "object",

  "definitions": {
    "numeric_stats": {
      "type": "object",
      "properties": {
        "mean":   { "type": "number" },
        "sqDiff": { "type": "number" }
      },
      "required": ["mean", "sqDiff"]
    },
    "node_ids": {
      "type": "array",
      "items": {
        "type": "int",
      },
    },
    "statistics": {
      "type": "object",
      "properties": {
        "firstAttemptCnt":   { "type": "number" },
        "maxRetries":        { "type": "number" },
        "numRows":           { "$ref": "#/definitions/numeric_stats" },
        "parseLat":          { "$ref": "#/definitions/numeric_stats" },
        "planLat":           { "$ref": "#/definitions/numeric_stats" },
        "runLat":            { "$ref": "#/definitions/numeric_stats" },
        "svcLat":            { "$ref": "#/definitions/numeric_stats" },
        "ovhLat":            { "$ref": "#/definitions/numeric_stats" },
        "bytesRead":         { "$ref": "#/definitions/numeric_stats" },
        "rowsRead":          { "$ref": "#/definitions/numeric_stats" }
        "firstExecAt":       { "type": "string" },
        "lastExecAt":        { "type": "string" },
        "nodes":             { "type": "node_ids" },
      },
      "required": [
        "firstAttemptCnt",
        "maxRetries",
        "numRows",
        "parseLat",
        "planLat",
        "runLat",
        "svcLat",
        "ovhLat",
        "bytesRead",
        "rowsRead",
        "nodes"
      ]
    },
    "execution_statistics": {
      "type": "object",
      "properties": {
        "cnt":             { "type": "number" },
        "networkBytes":    { "$ref": "#/definitions/numeric_stats" },
        "maxMemUsage":     { "$ref": "#/definitions/numeric_stats" },
        "contentionTime":  { "$ref": "#/definitions/numeric_stats" },
        "networkMsgs":     { "$ref": "#/definitions/numeric_stats" },
        "maxDiskUsage":    { "$ref": "#/definitions/numeric_stats" },
      },
      "required": [
        "cnt",
        "networkBytes",
        "maxMemUsage",
        "contentionTime",
        "networkMsgs",
        "maxDiskUsage",
      ]
    }
  },

  "properties": {
    "stats": { "$ref": "#/definitions/statistics" },
    "execStats": {
      "$ref": "#/definitions/execution_statistics"
    }
  }
}

func BuildTxnMetadataJSON

func BuildTxnMetadataJSON(statistics *roachpb.CollectedTransactionStatistics) (json.JSON, error)

BuildTxnMetadataJSON encodes the metadata portion a given roachpb.CollectedTransactionStatistics into a json.JSON object.

JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "system.transaction_statistics.metadata",
  "type": "object",
  "properties": {
    "stmtFingerprintIDs": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "firstExecAt": { "type": "string" },
    "lastExecAt":  { "type": "string" }
  }
}

TODO(azhng): add `firstExecAt` and `lastExecAt` into the protobuf definition.

func BuildTxnStatisticsJSON

func BuildTxnStatisticsJSON(statistics *roachpb.CollectedTransactionStatistics) (json.JSON, error)

BuildTxnStatisticsJSON encodes the statistics portion a given roachpb.CollectedTransactionStatistics into a json.JSON.

JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "system.statement_statistics.statistics",
  "type": "object",

  "definitions": {
    "numeric_stats": {
      "type": "object",
      "properties": {
        "mean":   { "type": "number" },
        "sqDiff": { "type": "number" }
      },
      "required": ["mean", "sqDiff"]
    },
    "statistics": {
      "type": "object",
      "properties": {
        "maxRetries": { "type": "number" },
        "numRows":    { "$ref": "#/definitions/numeric_stats" },
        "svcLat":     { "$ref": "#/definitions/numeric_stats" },
        "retryLat":   { "$ref": "#/definitions/numeric_stats" },
        "commitLat":  { "$ref": "#/definitions/numeric_stats" },
        "bytesRead":  { "$ref": "#/definitions/numeric_stats" },
        "rowsRead":   { "$ref": "#/definitions/numeric_stats" }
      },
      "required": [
        "maxRetries",
        "numRows",
        "svcLat",
        "retryLat",
        "commitLat",
        "bytesRead",
        "rowsRead",
      ]
    },
    "execution_statistics": {
      "type": "object",
      "properties": {
        "cnt":             { "type": "number" },
        "networkBytes":    { "$ref": "#/definitions/numeric_stats" },
        "maxMemUsage":     { "$ref": "#/definitions/numeric_stats" },
        "contentionTime":  { "$ref": "#/definitions/numeric_stats" },
        "networkMsg":      { "$ref": "#/definitions/numeric_stats" },
        "maxDiskUsage":    { "$ref": "#/definitions/numeric_stats" },
      },
      "required": [
        "cnt",
        "networkBytes",
        "maxMemUsage",
        "contentionTime",
        "networkMsg",
        "maxDiskUsage",
      ]
    }
  },

  "properties": {
    "stats": { "$ref": "#/definitions/statistics" },
    "execStats": {
      "$ref": "#/definitions/execution_statistics"
    }
  }
}

func DatumToUint64

func DatumToUint64(d tree.Datum) (uint64, error)

DatumToUint64 Convert a bytes datum to uint64.

func DecodeStmtStatsMetadataJSON

func DecodeStmtStatsMetadataJSON(
	metadata json.JSON, result *roachpb.CollectedStatementStatistics,
) error

DecodeStmtStatsMetadataJSON decodes the 'metadata' field of the JSON representation of the statement statistics into roachpb.CollectedStatementStatistics.

func DecodeStmtStatsStatisticsJSON

func DecodeStmtStatsStatisticsJSON(jsonVal json.JSON, result *roachpb.StatementStatistics) error

DecodeStmtStatsStatisticsJSON decodes the 'statistics' field and the 'execution_statistics' field in the given json into roachpb.StatementStatistics.

func DecodeTxnStatsMetadataJSON

func DecodeTxnStatsMetadataJSON(
	metadata json.JSON, result *roachpb.CollectedTransactionStatistics,
) error

DecodeTxnStatsMetadataJSON decodes the 'metadata' field of the JSON representation of transaction statistics into roachpb.CollectedTransactionStatistics.

func DecodeTxnStatsStatisticsJSON

func DecodeTxnStatsStatisticsJSON(jsonVal json.JSON, result *roachpb.TransactionStatistics) error

DecodeTxnStatsStatisticsJSON decodes the 'statistics' section of the transaction statistics JSON payload into roachpb.TransactionStatistics protobuf.

func EncodeUint64ToBytes

func EncodeUint64ToBytes(id uint64) []byte

EncodeUint64ToBytes returns the []byte representation of an uint64 value.

func ExplainTreePlanNodeToJSON

func ExplainTreePlanNodeToJSON(node *roachpb.ExplainTreePlanNode) json.JSON

ExplainTreePlanNodeToJSON builds a formatted JSON object from the explain tree nodes.

func GetRandomizedCollectedStatementStatisticsForTest

func GetRandomizedCollectedStatementStatisticsForTest(
	t *testing.T,
) (result roachpb.CollectedStatementStatistics)

GetRandomizedCollectedStatementStatisticsForTest returns a roachpb.CollectedStatementStatistics with its fields randomly filled.

func JSONToExplainTreePlanNode

func JSONToExplainTreePlanNode(jsonVal json.JSON) (*roachpb.ExplainTreePlanNode, error)

JSONToExplainTreePlanNode decodes the JSON-formatted ExplainTreePlanNode produced by ExplainTreePlanNodeToJSON.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL