Skip to main content
Glama
blitzstermayank

Teradata MCP Server

dba_tableUsageImpact

Analyze table and view usage by users to identify resource consumption patterns and optimize database performance in Teradata environments.

Instructions

Measure the usage of a table and views by users, this is helpful to understand what user and tables are driving most resource usage at any point in time.

Arguments: database_name - database name to analyze user_name - user name to analyze

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_nameNo
user_nameNo

Implementation Reference

  • Handler function for the dba_tableUsageImpact tool. Executes SQL query on DBQL tables to compute table usage statistics including query counts, first/last query timestamps, and usage frequency categories (High/Medium/Low). Supports optional filtering by database_name or user_name.
    def handle_dba_tableUsageImpact(conn: TeradataConnection, database_name: str | None = None, user_name: str | None = None, *args, **kwargs):
        """
        Measure the usage of a table and views by users, this is helpful to understand what user and tables are driving most resource usage at any point in time.
    
        Arguments:
          database_name - database name to analyze
          user_name - user name to analyze
    
        """
        logger.debug(f"Tool: handle_dba_tableUsageImpact: Args: database_name: {database_name}, user_name: {user_name}")
        database_name_filter = f"AND objectdatabasename = '{database_name}'" if database_name else ""
        user_name_filter = f"AND username = '{user_name}'" if user_name else ""
        table_usage_sql="""
        LOCKING ROW for ACCESS
        sel
        DatabaseName
        ,TableName
        ,UserName
        ,Weight as "QueryCount"
        ,100*"Weight" / sum("Weight") over(partition by 1) PercentTotal
        ,case
            when PercentTotal >=10 then 'High'
            when PercentTotal >=5 then 'Medium'
            else 'Low'
        end (char(6)) usage_freq
        ,FirstQueryDaysAgo
        ,LastQueryDaysAgo
    
        from
        (
            SELECT   TRIM(QTU1.TableName)  AS "TableName"
                    , TRIM(QTU1.DatabaseName)  AS "DatabaseName"
                    ,UserName as "UserName"
                    ,max((current_timestamp - CollectTimeStamp) day(4)) as "FirstQueryDaysAgo"
                    ,min((current_timestamp - CollectTimeStamp) day(4)) as "LastQueryDaysAgo"
                    , COUNT(DISTINCT QTU1.QueryID) as "Weight"
            FROM    (
                        SELECT   objectdatabasename AS DatabaseName
                            , ObjectTableName AS TableName
                            , ob.QueryId
                        FROM DBC.DBQLObjTbl ob /* uncomment for DBC */
                        WHERE Objecttype in ('Tab', 'Viw')
                        {database_name_filter}
                        AND ObjectTableName IS NOT NULL
                        AND ObjectColumnName IS NULL
                        -- AND LogDate BETWEEN '2017-01-01' AND '2017-08-01' /* uncomment for PDCR */
                        --	AND LogDate BETWEEN current_date - 90 AND current_date - 1 /* uncomment for PDCR */
                        GROUP BY 1,2,3
                            ) AS QTU1
            INNER JOIN DBC.DBQLogTbl QU /* uncomment for DBC */
            ON QTU1.QueryID=QU.QueryID
            AND (QU.AMPCPUTime + QU.ParserCPUTime) > 0
            {user_name_filter}
    
            GROUP BY 1,2, 3
        ) a
        order by PercentTotal desc
        qualify PercentTotal>0
        ;
    
        """
        logger.debug(f"Tool: handle_dba_tableUsageImpact: table_usage_sql: {table_usage_sql}")
        with conn.cursor() as cur:
            logger.debug("Database version information requested.")
            rows = cur.execute(table_usage_sql.format(database_name_filter=database_name_filter, user_name_filter=user_name_filter))
            data = rows_to_json(cur.description, rows.fetchall())
        if len(data):
            info=f'This data contains the list of tables most frequently queried objects in database schema {database_name}'
        else:
            info=f'No tables have recently been queried in the database schema {database_name}.'
        metadata = {
            "tool_name": "handle_dba_tableUsageImpact",
            "database": database_name,
            "table_count": len(data),
            "comment": info,
            "rows": len(data)
        }
        logger.debug(f"Tool: handle_dba_tableUsageImpact: metadata: {metadata}")
        return create_response(data, metadata)
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions measuring usage and understanding resource drivers, but fails to disclose critical behavioral traits: whether this is a read-only operation, if it requires specific permissions, potential performance impact, rate limits, or output format. For a tool with 'dba' prefix suggesting administrative functions, this omission is significant.

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 appropriately concise with two sentences: one stating the purpose and benefit, followed by a structured 'Arguments' list. It's front-loaded with the core function. While efficient, the second sentence could be more direct, and the structure is clear but not perfectly polished.

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

Completeness2/5

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

Given the complexity (administrative usage analysis), lack of annotations, no output schema, and low schema coverage, the description is incomplete. It covers basic purpose and parameters but misses behavioral context, output details, and sibling differentiation. For a tool likely involving system metrics, more guidance on permissions, impact, and result interpretation is needed.

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 0%, but the description includes an 'Arguments' section that lists and briefly describes both parameters ('database_name - database name to analyze', 'user_name - user name to analyze'). This adds meaningful semantics beyond the schema's titles, clarifying their purpose. However, it doesn't detail format, constraints, or interaction effects, leaving gaps.

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?

The description clearly states the tool's purpose: 'Measure the usage of a table and views by users' with the goal of 'understanding what user and tables are driving most resource usage.' This specifies the verb (measure), resource (table and views usage), and context (resource usage analysis). However, it doesn't explicitly differentiate from sibling tools like 'base_tableUsage' or 'dba_featureUsage,' which likely have overlapping purposes.

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 minimal guidance: 'this is helpful to understand what user and tables are driving most resource usage at any point in time.' It implies usage for resource analysis but offers no explicit when-to-use instructions, alternatives (e.g., vs. 'base_tableUsage'), prerequisites, or exclusions. Without clear differentiation from siblings, the agent lacks context for tool selection.

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/blitzstermayank/MCP'

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