Getting ready

Here, we will look at some basic rules that need to be kept in mind when executing queries:

  • Know your data: Understand the relationships between tables, know your data, and fetch only the required columns.
  • Visualize the answer set: Don't just keep on pulling the handle till you hit the jackpot; always try to know the count of possible rows expected.
  • Break your queries: Use the various features of the database. Try volatile tables to do the calculations and then join it with the main query, or explore the option of breaking date range that turns YEARs queries into MONTHs.
  • JOINS: Be reasonable with CROSS JOIN or LEFT joins. Bad joins with skew values result in high CPU and IO queries.
  • Data types: Ensure appropriate data types ...

Get Teradata Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.