Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

dba_resusageSummary

Analyze Teradata system resource usage by aggregating metrics across dimensions like workload type, complexity, time, and user to identify performance patterns and optimize database efficiency.

Instructions

Get the Teradata system usage summary metrics by weekday and hour for each workload type and query complexity bucket.

Arguments: dimensions - list of dimensions to aggregate the resource usage summary. All dimensions are: ["LogDate", "hourOfDay", "dayOfWeek", "workloadType", "workloadComplexity", "UserName", "AppId"] user_name - user name date - Date to analyze, formatted as YYYY-MM-DD dayOfWeek - day of the week to analyze hourOfDay - hour of day to analyze workloadType - workload type to analyze, example: 'LOAD', 'ETL/ELT', 'EXPORT', 'QUERY', 'ADMIN', 'OTHER' workloadComplexity - workload complexity to analyze, example: 'Ingest & Prep', 'Answers', 'System/Procedural' AppId - Application ID to analyze, example: 'TPTLOAD%', 'TPTUPD%', 'FASTLOAD%', 'MULTLOAD%', 'EXECUTOR%', 'JDBC%'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dimensionsNo
user_nameNo
dateNo
dayOfWeekNo
hourOfDayNo
workloadTypeNo
workloadComplexityNo
AppIdNo

Implementation Reference

  • Handler function implementing the dba_resusageSummary tool. Dynamically builds and executes a SQL query on DBQLogTbl to summarize resource usage (CPU, IO, etc.) aggregated by user-specified dimensions and filters (date, user, workload, etc.). Returns formatted JSON response with metadata.
    def handle_dba_resusageSummary(conn: TeradataConnection,
                                     dimensions: list[str] | None = None,
                                     user_name: str | None = None,
                                     date:  str | None = None,
                                     dayOfWeek:  str | None = None,
                                     hourOfDay:  str | None = None,
                                     workloadType: str | None = None,
                                     workloadComplexity: str | None = None,
                                     AppId: str | None = None,
                                     *args, **kwargs):
    
        """
        Get the Teradata system usage summary metrics by weekday and hour for each workload type and query complexity bucket.
    
        Arguments:
          dimensions - list of dimensions to aggregate the resource usage summary. All dimensions are: ["LogDate", "hourOfDay", "dayOfWeek", "workloadType", "workloadComplexity", "UserName", "AppId"]
          user_name - user name
          date - Date to analyze, formatted as `YYYY-MM-DD`
          dayOfWeek - day of the week to analyze
          hourOfDay - hour of day to analyze
          workloadType - workload type to analyze, example: 'LOAD', 'ETL/ELT', 'EXPORT', 'QUERY', 'ADMIN', 'OTHER'
          workloadComplexity - workload complexity to analyze, example: 'Ingest & Prep', 'Answers', 'System/Procedural'
          AppId - Application ID to analyze, example: 'TPTLOAD%', 'TPTUPD%', 'FASTLOAD%', 'MULTLOAD%', 'EXECUTOR%', 'JDBC%'
    
        """
        logger.debug(f"Tool: handle_dba_resusageSummary: Args: dimensions: {dimensions}")
    
        comment="Total system resource usage summary."
    
        # If dimensions is not None or empty, filter in the allowed dimensions
        allowed_dimensions = ["LogDate", "hourOfDay", "dayOfWeek", "workloadType", "workloadComplexity","UserName","AppId"]
        unsupported_dimensions = []
        if dimensions is not None:
            unsupported_dimensions = [dim for dim in dimensions if dim not in allowed_dimensions]
            dimensions = [dim for dim in dimensions if dim in allowed_dimensions]
        else:
            dimensions=[]
    
    
        # Update comment string based on dimensions used and supported.
        if dimensions:
            comment+="Metrics aggregated by " + ", ".join(dimensions) + "."
        if unsupported_dimensions:
            comment+="The following dimensions are not supported and will be ignored: " + ", ".join(unsupported_dimensions) + "."
    
        # Dynamically construct the SELECT and GROUP BY clauses based on dimensions
        dim_string = ", ".join(dimensions)
        group_by_clause = ("GROUP BY " if dimensions else "")+dim_string
        dim_string += ("," if dimensions else "")
    
        filter_clause = ""
        filter_clause += f"AND UserName = '{user_name}' " if user_name else ""
        filter_clause += f"AND LogDate = '{date}' " if date else ""
        filter_clause += f"AND dayOfWeek = '{dayOfWeek}' " if dayOfWeek else ""
        filter_clause += f"AND hourOfDay = '{hourOfDay}' " if hourOfDay else ""
        filter_clause += f"AND workloadType = '{workloadType}' " if workloadType else ""
        filter_clause += f"AND workloadComplexity = '{workloadComplexity}' " if workloadComplexity else ""
        filter_clause += f"AND AppID LIKE '{AppId}' " if AppId else ""
    
        query = f"""
        SELECT
            {dim_string}
            COUNT(*) AS "Request Count",
            SUM(AMPCPUTime) AS "Total AMPCPUTime",
            SUM(TotalIOCount) AS "Total IOCount",
            SUM(ReqIOKB) AS "Total ReqIOKB",
            SUM(ReqPhysIO) AS "Total ReqPhysIO",
            SUM(ReqPhysIOKB) AS "Total ReqPhysIOKB",
            SUM(SumLogIO_GB) AS "Total ReqIO GB",
            SUM(SumPhysIO_GB) AS "Total ReqPhysIOGB",
            SUM(TotalServerByteCount) AS "Total Server Byte Count"
        FROM
            (
                SELECT
                    CAST(QryLog.Starttime as DATE) AS LogDate,
                    EXTRACT(HOUR FROM StartTime) AS hourOfDay,
                    CASE QryCal.day_of_week
                        WHEN 1 THEN 'Sunday'
                        WHEN 2 THEN 'Monday'
                        WHEN 3 THEN 'Tuesday'
                        WHEN 4 THEN 'Wednesday'
                        WHEN 5 THEN 'Thursday'
                        WHEN 6 THEN 'Friday'
                        WHEN 7 THEN 'Saturday'
                    END AS dayOfWeek,
                    QryLog.UserName,
                    QryLog.AcctString,
                    QryLog.AppID ,
                    CASE
                        WHEN QryLog.AppID LIKE ANY('TPTLOAD%', 'TPTUPD%', 'FASTLOAD%', 'MULTLOAD%', 'EXECUTOR%', 'JDBCL%') THEN 'LOAD'
                        WHEN QryLog.StatementType IN ('Insert', 'Update', 'Delete', 'Create Table', 'Merge Into')
                            AND QryLog.AppID NOT LIKE ANY('TPTLOAD%', 'TPTUPD%', 'FASTLOAD%', 'MULTLOAD%', 'EXECUTOR%', 'JDBCL%') THEN 'ETL/ELT'
                        WHEN QryLog.StatementType = 'Select' AND (AppID IN ('TPTEXP', 'FASTEXP') OR AppID LIKE 'JDBCE%') THEN 'EXPORT'
                        WHEN QryLog.StatementType = 'Select'
                            AND QryLog.AppID NOT LIKE ANY('TPTLOAD%', 'TPTUPD%', 'FASTLOAD%', 'MULTLOAD%', 'EXECUTOR%', 'JDBCL%') THEN 'QUERY'
                        WHEN QryLog.StatementType IN ('Dump Database', 'Unrecognized type', 'Release Lock', 'Collect Statistics') THEN 'ADMIN'
                        ELSE 'OTHER'
                    END AS workloadType,
                    CASE
                        WHEN StatementType = 'Merge Into' THEN 'Ingest & Prep'
                        WHEN StatementType = 'Select' THEN 'Answers'
                        ELSE 'System/Procedural'
                    END AS workloadComplexity,
                    QryLog.AMPCPUTime,
                    QryLog.TotalIOCount,
                    QryLog.ReqIOKB,
                    QryLog.ReqPhysIO,
                    QryLog.ReqPhysIOKB,
                    QryLog.TotalServerByteCount,
                    (QryLog.ReqIOKB / 1024 / 1024) AS SumLogIO_GB,
                    (QryLog.ReqPhysIOKB / 1024 / 1024) AS SumPhysIO_GB
                FROM
                    DBC.DBQLogTbl QryLog
                    INNER JOIN Sys_Calendar.CALENDAR QryCal
                        ON QryCal.calendar_date = CAST(QryLog.Starttime as DATE)
                WHERE
                    CAST(QryLog.Starttime as DATE) BETWEEN CURRENT_DATE - 30 AND CURRENT_DATE
                    AND StartTime IS NOT NULL
                    {filter_clause}
            ) AS QryDetails
            {group_by_clause}
        """
        logger.debug(f"Tool: handle_dba_resusageSummary: Query: {query}")
        with conn.cursor() as cur:
            logger.debug("Resource usage summary requested.")
            rows = cur.execute(query)
    
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "dba_resusageSummary",
                "total_rows": len(data) ,
                "comment": comment,
                "rows": len(data)
            }
            logger.debug(f"Tool: handle_dba_resusageSummary: metadata: {metadata}")
            return create_response(data, metadata)
  • Docstring providing input schema and description for the tool parameters, serving as the tool's input schema documentation.
    """
    Get the Teradata system usage summary metrics by weekday and hour for each workload type and query complexity bucket.
    
    Arguments:
      dimensions - list of dimensions to aggregate the resource usage summary. All dimensions are: ["LogDate", "hourOfDay", "dayOfWeek", "workloadType", "workloadComplexity", "UserName", "AppId"]
      user_name - user name
      date - Date to analyze, formatted as `YYYY-MM-DD`
      dayOfWeek - day of the week to analyze
      hourOfDay - hour of day to analyze
      workloadType - workload type to analyze, example: 'LOAD', 'ETL/ELT', 'EXPORT', 'QUERY', 'ADMIN', 'OTHER'
      workloadComplexity - workload complexity to analyze, example: 'Ingest & Prep', 'Answers', 'System/Procedural'
      AppId - Application ID to analyze, example: 'TPTLOAD%', 'TPTUPD%', 'FASTLOAD%', 'MULTLOAD%', 'EXECUTOR%', 'JDBC%'
  • Metadata dictionary within the handler that explicitly identifies the tool name as 'dba_resusageSummary', likely used in tool registration or response formatting.
    metadata = {
        "tool_name": "dba_resusageSummary",
        "total_rows": len(data) ,
        "comment": comment,
        "rows": len(data)
    }
    logger.debug(f"Tool: handle_dba_resusageSummary: metadata: {metadata}")
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it clearly describes what the tool retrieves, it doesn't mention important behavioral aspects like whether this is a read-only operation, potential performance impact on the Teradata system, authentication requirements, rate limits, or what format the results are returned in. The description is purely functional without operational context.

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?

The description is well-structured with a clear purpose statement followed by detailed parameter explanations. While the parameter section is lengthy (necessary given 8 parameters), it's organized efficiently with bullet-like formatting. Every sentence serves a purpose, though the description could be slightly more concise by combining some parameter explanations.

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

Completeness3/5

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

Given the tool's complexity (8 parameters, no annotations, no output schema), the description provides good functional coverage but lacks operational context. It thoroughly explains what the tool does and how to use parameters, but doesn't address behavioral aspects like system impact, result format, or error conditions. For a data retrieval tool with many parameters, more operational guidance would be helpful.

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

Parameters5/5

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

With 0% schema description coverage and 8 parameters, the description provides excellent parameter semantics. It clearly explains each parameter's purpose, provides the complete list of dimensions, and gives concrete examples for workloadType, workloadComplexity, and AppId. This fully compensates for the lack of schema descriptions and gives the agent clear guidance on how to use each parameter.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verb ('Get') and resource ('Teradata system usage summary metrics'), specifying the aggregation dimensions ('by weekday and hour for each workload type and query complexity bucket'). It distinguishes itself from siblings like 'dba_featureUsage' or 'dba_userDelay' by focusing specifically on resource usage summaries with temporal and workload dimensions.

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?

The description provides no guidance on when to use this tool versus alternatives. While it mentions dimensions like 'workloadType' and 'workloadComplexity', it doesn't explain when to choose this tool over other dba_* tools like 'dba_featureUsage' or 'dba_userSqlList' for similar analysis needs. No exclusions, prerequisites, or alternative tools are mentioned.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Teradata/teradata-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server