Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 26 Nov 2010 @ 12:17:18 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Pros and Cons of Stored Procedures
 
From:   Dieter Noeth

Faible Mou wrote:

  Interesting, no one is mentioning what I was expecting for. I heard some companies are avoiding stored procedures because they only run on single AMPs. Is that true?  


SPs are transformed into a C-program and compiled into a ".so" on Unix or a ".DLL" on windows with an exported function, this file is stored within Teradata.

When you CALL the SP, it's materialized (and cached) in the file system of the node your PE is running on.

So it runs on a single node, but only the flow control statements, the SQL still runs the same as always.

If you got an endless loop without any SQL, you might see a single cpu on that node running at a 100%.

And this is not recorded as cpu usage in Teradata, this is one of the reasons DBAs don't like it.

Another one is cursors, these are *evil* (unless you use them in the way JK described). Imagine a cursor iterating over a 1 million row answer set serially using "fetch next", this is bad on any DBMS (even if you don't use nested cursors), but in a parallel DBMS it's worst case.

You might have a 100 node system, but the cursor is running on a single node. Probably all of those cursors might be re-written using OLAP functions or recursie SQL, both run in parallel.


  Moreover, are stored procedures like marcos, in the sense that the whole procedure is regarded as a single transaction, and will rollback the whole thing if anything goes wrong?  


No, an SP is part of the calling session.

In ANSI mode there must be a COMMIT after or within the SP. In an explicit transaction in Teradata mode using BT there must be an ET after or within the SP.

In an implicit transaction in Teradata mode each statement in an SP is a separate transaction unless you bundle them into a multistatement request using BEGIN/END.

Btw, you usually don't find newbies reading so thoroughly through the documentation. Well done for a wimp ;-)


Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023