Monthly Archives: December 2009

Get TeraData to tell you which columns need stats collecting

If you have TeraData SQL queries that you run regularly (e.g. as part of a report or ETL process) you’ll want to ensure that those queries are performing as efficiently as possible.

Often, keeping up to date statistics on your tables can be one way to keeping query times on track.

TeraData has a helpful session setting that will give you a listing of all columns that should have stats collected.

Here’s how to use it.

1) Open a new connection in SQL Assistant
2) Run the following statement: diagnostic helpstats on for session
3) Run an explain plan on your SQL query (just put the keyword “explain” in front of your select e.g. explain select * from w_day_d)
4) If you need any stats collecting you’ll find the following message at the bottom of your explain plan in the results window:
BEGIN RECOMMENDED STATS ->
“COLLECT STATISTICS R2PRD1.WC_ASSET_SCD COLUMN ISSUE_DT”.
(HighConf)
“COLLECT STATISTICS R2PRD1.WC_ASSET_SCD COLUMN GRATIS_INDICATOR”.
(HighConf)
“COLLECT STATISTICS R2PRD1.WC_ASSET_SCD COLUMN O75_TYPE”.
(HighConf)
“COLLECT STATISTICS R2PRD1.WC_ASSET_SCD COLUMN START_DT”.
(HighConf)
<- END RECOMMENDED STATS

Backing up and restoring Windows Media Center schedules and recordings in Win7

Right, I’m about to bite the bullet and flatten my office laptop and do a clean install of Win 7.

I use the office laptop as a “server” for our home entertainment solution. I’ve got Windows Media Center running with a Hauppauge dual tuner USB stick. In our bedroom and the lounge we’ve got a Linksys DMA 2100 Media Center extender, both connected to the laptop via a 200Mb Devolo Ethernet over Power network adapters.

I’ve also installed My Movies 3 on the laptop and am in the process of ripping our DVD collection onto my 1Tb Western Digitial My Book external hard drive.

What I want to be able to do is to reinstall Win 7 and not have to either lose programs already recorded or have to go through and set up our recording schedule again. I initially performed an upgrade from Vista to Win7 as I’d read that the way Win 7 Media Center stores its information is different to Vista. So, now I’m in Win 7 I should just be able to do a straightforward backup and restore. This link showed me how:
http://www.hack7mc.com/2009/03/backup-and-restore-recording-schedule.html

Extracting Month and Year from a date in Teradata

select cast ((cast(current_date as format ‘mmm’)) as char(3))

select cast ((cast(current_date as format ‘yyyy’)) as char(4))

Nice and easy that one!

Only caveat is that if you have your dates stored in Timestamp fields you’ll need an extra cast up front to convert the timestamp to a date:
select
cast(cast(cast(issue_dt as date) as format ‘mmm’) as char(3))
from
wc_asset_d