Skip to main content
Glama

PostgreSQL Query Cost Estimator

query-cost-estimator
Read-onlyIdempotent

Estimate PostgreSQL sequential-scan and index-scan cost from table rows, table pages, selectivity, and storage type. Uses the same four-input model as the browser calculator.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_rowsYestable rows used by this deterministic tool.
table_pagesYestable pages used by this deterministic tool.
storage_typeYesstorage type; accepted values: ssd, nvme, hdd, network.
selectivity_pctYesselectivity expressed as a percentage.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
next_stepYes
cost_ratioYes
index_pagesYes
index_tuplesYes
storage_typeYes
next_step_urlYes
why_follow_upYes
interpretationYes
index_scan_costYes
random_page_costYes
recommended_planYes
affiliate_contextNo
computation_basisYes
sequential_scan_costYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedOutput schema / properties / storage_type
      Added value: +{
      +  "type": "string"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "computation_basis",
      -  "cost_ratio",
      -  "index_pages",
      -  "index_scan_cost",
      -  "index_tuples",
      -  "interpretation",
      -  "next_step",
      -  "next_step_url",
      -  "random_page_cost",
      -  "recommended_plan",
      -  "sequential_scan_cost",
      -  "why_follow_up"
      -]New value: +[
      +  "computation_basis",
      +  "cost_ratio",
      +  "index_pages",
      +  "index_scan_cost",
      +  "index_tuples",
      +  "interpretation",
      +  "next_step",
      +  "next_step_url",
      +  "random_page_cost",
      +  "recommended_plan",
      +  "sequential_scan_cost",
      +  "storage_type",
      +  "why_follow_up"
      +]
  2. Changed18 schema fields changed
    • removedInput schema / properties / query
      Removed value: -{
      -  "description": "SQL query to analyze",
      -  "type": "string"
      -}
    • addedInput schema / properties / selectivity_pct
      Added value: +{
      +  "description": "selectivity expressed as a percentage.",
      +  "examples": [
      +    1
      +  ],
      +  "maximum": 100,
      +  "minimum": 0,
      +  "type": "number"
      +}
    • addedInput schema / properties / storage_type
      Added value: +{
      +  "description": "storage type; accepted values: ssd, nvme, hdd, network.",
      +  "enum": [
      +    "ssd",
      +    "nvme",
      +    "hdd",
      +    "network"
      +  ],
      +  "examples": [
      +    "ssd"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / table_pages
      Added value: +{
      +  "description": "table pages used by this deterministic tool.",
      +  "examples": [
      +    1
      +  ],
      +  "minimum": 1,
      +  "type": "number"
      +}
    • addedInput schema / properties / table_rows
      Added value: +{
      +  "description": "table rows used by this deterministic tool.",
      +  "examples": [
      +    1
      +  ],
      +  "minimum": 1,
      +  "type": "number"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "query"
      -]New value: +[
      +  "table_rows",
      +  "table_pages",
      +  "selectivity_pct",
      +  "storage_type"
      +]
    • removedOutput schema / properties / cost_level
      Removed value: -{
      -  "type": "string"
      -}
    • addedOutput schema / properties / cost_ratio
      Added value: +{
      +  "type": "number"
      +}
    • removedOutput schema / properties / cost_score
      Removed value: -{
      -  "type": "number"
      -}
    • addedOutput schema / properties / index_pages
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / index_scan_cost
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / index_tuples
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / random_page_cost
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / recommended_plan
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / sequential_scan_cost
      Added value: +{
      +  "type": "number"
      +}
    • removedOutput schema / properties / warning_count
      Removed value: -{
      -  "type": "number"
      -}
    • removedOutput schema / properties / warnings
      Removed value: -{
      -  "items": {
      -    "type": "string"
      -  },
      -  "type": "array"
      -}
    • changedOutput schema / required
      Previous value: -[
      -  "computation_basis",
      -  "cost_level",
      -  "cost_score",
      -  "interpretation",
      -  "next_step",
      -  "next_step_url",
      -  "warning_count",
      -  "warnings",
      -  "why_follow_up"
      -]New value: +[
      +  "computation_basis",
      +  "cost_ratio",
      +  "index_pages",
      +  "index_scan_cost",
      +  "index_tuples",
      +  "interpretation",
      +  "next_step",
      +  "next_step_url",
      +  "random_page_cost",
      +  "recommended_plan",
      +  "sequential_scan_cost",
      +  "why_follow_up"
      +]
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "affiliate_context": {
      +      "additionalProperties": false,
      +      "properties": {
      +        "affiliate": {
      +          "type": "string"
      +        },
      +        "cta_label": {
      +          "type": "string"
      +        },
      +        "disclosure": {
      +          "type": "string"
      +        },
      +        "framing": {
      +          "type": "string"
      +        },
      +        "posture": {
      +          "enum": [
      +            "secondary"
      +          ],
      +          "type": "string"
      +        },
      +        "slot_id": {
      +          "type": "string"
      +        },
      +        "url": {
      +          "type": "string"
      +        },
      +        "variant": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "affiliate",
      +        "cta_label",
      +        "disclosure",
      +        "framing",
      +        "posture",
      +        "slot_id",
      +        "url",
      +        "variant"
      +      ],
      +      "type": "object"
      +    },
      +    "computation_basis": {
      +      "type": "string"
      +    },
      +    "cost_level": {
      +      "type": "string"
      +    },
      +    "cost_score": {
      +      "type": "number"
      +    },
      +    "interpretation": {
      +      "type": "string"
      +    },
      +    "next_step": {
      +      "type": "string"
      +    },
      +    "next_step_url": {
      +      "type": "string"
      +    },
      +    "warning_count": {
      +      "type": "number"
      +    },
      +    "warnings": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "why_follow_up": {
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "computation_basis",
      +    "cost_level",
      +    "cost_score",
      +    "interpretation",
      +    "next_step",
      +    "next_step_url",
      +    "warning_count",
      +    "warnings",
      +    "why_follow_up"
      +  ],
      +  "type": "object"
      +}
  4. Changed1 schema field changed
    • addedInput schema / additionalProperties
      Added value: +false
  5. First observed

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources