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

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

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

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, openWorldHint=false, and destructiveHint=false, so the safe deterministic profile is covered. The description adds that this is a pure estimate using a known four-input model, consistent with the annotations, but adds no extra behavioral context beyond that.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the operation and its inputs, with no padding. The trailing sentence about the browser calculator is mildly useful context rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained, and annotations carry the safety profile. For a deterministic estimator with fully documented parameters, the description is complete enough, though a note on the underlying cost model would add value.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all four parameters (table_rows, table_pages, selectivity_pct, storage_type) are already documented, including the storage_type enum. The description only restates the input list without adding syntax or modeling detail, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (Estimate) and a precise resource (PostgreSQL sequential-scan and index-scan cost), then names the four inputs. It is clearly distinguishable from sibling cost calculators (ec2-cost-calculator, terraform-plan-cost-estimator) though it does not explicitly contrast itself with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use, when-not-to-use, or alternative-tool guidance. The reference to 'the same four-input model as the browser calculator' gives context about consistency but tells the agent nothing about when this tool is the right pick.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources