Professional Documents
Culture Documents
Query to check if any of the SPU's are running slower than the rest:
(This actually gives the read-write speed of each SPU that is online)
SELECT HWID, BYTE_COUNT/TOTAL_MSEC
FROM
_VT_DISK_TIMING
ORDER BY 2;
One more query.. To get the list of tables and their skew and size:
SELECT TABLENAME,OBJTYPE,OWNER,CREATEDATE,USED_BYTES,SKEW
FROM _V_TABLE_ONLY_STORAGE_STAT
WHERE OBJCLASS = 4905 OR OBJCLASS = 4911
ORDER BY TABLENAME;
How to schedule a cron job to run every 1st and 3rd Friday of the month
15 20 1-7, 15-21
* * bash -c . ~/.bashrc ; [ "`date +\%a`" = "Fri" ] && /my_server/scripts/backup.bsh >>
/my_server/log/backup.log_`date +\%Y\%m\%d` 2>&1
How to schedule a cron job to run every 2nd and 4th Friday of the month
05 20 8-14, 22-28
* * bash -c . ~/.bashrc ; [ "`date +\%a`" = "Fri" ] && /my_server/scripts/backup.bsh >>
/my_server/scripts/backup.log_`date +\%Y\%m\%d` 2>&1
How to schedule a cron job to run every first Saturday of each month at 2:10 PM
10 14 1-7
* * bash -c . ~/.bashrc ; [ "`date +\%a`" = "Sat" ] && /my_server/scripts/backup.sh >>
/my_server/scripts/backup.log_`date +\%Y\%m\%d` 2>&1
To check Databases without any backup:
Select datname DatabaseName from _T_database where datname not in (select dbname from
_v_backup_history) and datname not like 'MASTER_DB'
Useful Tips:
The great thing about Netezza is it does soft deletes until the groom process runs. This means your
deleted data is really still there. This is of course very important if you just deleted something you didnt
mean too. And since updates are really just a delete of the old values and an insert of the new behind
the scenes, you can actually undo updates too.
So first a little about how Netezza handles transactions. Every insert, update, or delete transaction is
assigned a sequential transaction id or xid. You can see this id by querying the column create xid . Also
there is a column to indicate deleted rows called delete xid. This is set to 0 if this is a readable, not
deleted row. When the row gets deleted, this column gets populated with the transaction id assigned to
the delete or update statement. And as I mentioned above, updates are handled by doing a delete of the
old record and inserting the entire new row with the new values.
Under normal circumstances when you run a select you will not see rows that have a delete xid not equal
to zero. But there is a simple session variable that can be set that allows you to see these deleted rows.
The simple command to run in your favorite query tool is
set show_deleted_records = true
So to see whats there you can then just select from your table and include the 2 transaction id
columns, like ...
Select createxid, delete xid, * from your_table
If you want to see just the deleted rows, just select where deletexid is not zero
Select createxid, deletexid, * from your_table where deletexid! =0
Once you can see your deleted data, and figure out which transaction you are trying to undo, you
can simply re-insert the data
insert into your_table select * from your_table where deletexid=233443; transaction id from delete.
To undo an update, just re-insert the deleted rows and delete the inserted rows.
insert into your_table select * from your_table where deletexid=233443;transaction id from update
delete from your_table where createxid=233443; transaction id from update
And Im stating the obvious, but to undo an insert, you dont even need to show deleted rows, just
delete by the transaction id
delete from your_table where createxid=233443; transaction id from insert