Step-by-Step: Open Teradata Viewer for SQL Query Inspection
What you’ll need
- Teradata Viewpoint or Teradata client installed (Teradata Studio, Teradata SQL Assistant, or another viewer that supports TD query inspection).
- Credentials with permission to view queries on the target Teradata system.
- Network access to the Teradata server (VPN or direct connection if required).
1. Launch the viewer application
- Open your chosen Teradata client (e.g., Teradata Viewpoint web console, Teradata Studio, or SQL Assistant).
- If using Viewpoint, point your browser to the Viewpoint URL and sign in with your credentials.
2. Connect to the Teradata system
- In the client, create or select a connection profile for the target Teradata host.
- Enter hostname/IP, port (default 1025 for some clients), username, and password. Save the profile if you will reuse it.
- Test the connection and connect.
3. Navigate to the query inspection area
- Teradata Viewpoint: Open the “Query Monitor” or “Viewpoint Performance” portlets (such as Query Monitor, DBQL Query Log, or Query Grid) to see active and recent queries.
- Teradata Studio: Use the “SQL History” or “Query Monitor” perspective/tab.
- SQL Assistant: Use the “History” or “DBQL” report to view past queries.
4. Locate the query you want to inspect
- Filter by user, time range, client application, or SQL text to narrow results.
- Sort by start time, elapsed time, or CPU to find slow or relevant queries.
- Select the query from the list to view details.
5. Inspect query details
- SQL text: Review the full statement to confirm what was executed.
- Execution plan: Open the explain plan to see join order, indexes, and cost estimates.
- Resource usage: Check elapsed time, CPU, I/O, and spool usage to assess performance impact.
- Session info: Note session ID, user, client, and node(s) involved.
- DBQL/Query Log: If enabled, review DBQL fields for compilation time, parsing, and associated metrics.
6. Use Explain and Visual Explain
- Copy the SQL text into the Explain feature (or right-click → Explain) in your viewer.
- Run Explain to generate a textual plan; open Visual Explain if available for a graphical plan showing steps and estimated costs.
- Interpret join types (hash, merge), redistribution steps, and hotspots where data moves between AMPs.
7. Diagnose common performance issues
- Skewed data distribution: Look for steps with uneven AMP work or high spool on specific nodes.
- Large redistributions: Identify unnecessary repartitions or product joins causing network cost.
- Missing statistics: Check for Full or Partial scans that indicate missing stats; collect stats as needed.
- Poor indexing: Examine access paths that fall back to full table scans.
8. Take corrective actions
- Add or update statistics on columns used in joins and predicates.
- Rewrite queries to reduce redistributions (e.g., use joins on well-distributed columns, avoid functions on join keys).
- Consider primary index changes or partitioning for long-term fixes.
- Test changes in a non-production environment and re-run Explain to compare plans.
9. Save and export findings
- Export the SQL, Explain plan, and metrics as files or screenshots for reporting.
- Document session IDs and timestamps for follow-up with DBAs or developers.
10. Follow-up monitoring
- Re-run queries during peak load to ensure fixes hold.
- Use Viewpoint dashboards or scheduled DBQL reports to track regressions over time.
Tips
- Always run Explain without executing the query in production when possible.
- Use time filters and user filters to reduce noise when searching logs.
- Coordinate with DBAs when making changes to statistics, indexes, or primary indices.
If you want, I can tailor these steps to a specific Teradata viewer (Viewpoint, Studio, or SQL Assistant) — tell me which one and I’ll adapt the walkthrough.
Leave a Reply