Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Teradata query doubt important - response (8) by dnoeth

$
0
0
You should try to avoid loops and cursor logic (which is serial) in a parallel database system :-) You can use any table with numbers in it, you could even use a ROW_NUMBER on any table large enough. Sys_calendar is just handy, as it exists on every system, it's only limited to 73414 rows. This is how i create my number table, you could use the same logic within a SP without the INSERT: /*** Helper table with integer values from 0 to x (9999999) ***/ CREATE VOLATILE TABLE vt_nums ( n INT) ON COMMIT PRESERVE ROWS; INSERT INTO vt_nums VALUES(0) ;INSERT INTO vt_nums VALUES(1) ;INSERT INTO vt_nums VALUES(2) ;INSERT INTO vt_nums VALUES(3) ;INSERT INTO vt_nums VALUES(4) ;INSERT INTO vt_nums VALUES(5) ;INSERT INTO vt_nums VALUES(6) ;INSERT INTO vt_nums VALUES(7) ;INSERT INTO vt_nums VALUES(8) ;INSERT INTO vt_nums VALUES(9) CREATE TABLE numbers(n INT NOT NULL PRIMARY KEY); INSERT INTO numbers SELECT i1.n + i2.n * 10 + i3.n * 100 + i4.n * 1000 + i5.n * 10000 + i6.n * 100000 FROM vt_nums i1, vt_nums i2, vt_nums i3, vt_nums i4, vt_nums i5, vt_nums i6 ; DROP TABLE vt_nums; COLLECT STATISTICS ON numbers COLUMN n; Dieter

Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>