Hi SCN,
Need your help in understanding Pros and Cons of usingTemporary Tables:
Creating this thread as a continuation with discussion in another thread mentioned below as suggested :
CREATE TABLE ... AS SELECT query with placeholders fails
So these are the observations i had on usage of temporary tables : ( All the SQL i learnt till now was on SAP HANA as i don have prior experience using SQL on other databases ). So when i was working with colleagues of mine who worked more on databases like Teradata ( From whom i learnt SQL ) there were some views on Temporary tables as listed below :
1) Locking may happen when multiple users use that procedure, but i see it is a session specific structure , i did not see the possibility of "Locking" ( need your inputs whether my understanding was correct )
2) We created a shell script to test the performance of the procedure when multiple users try to access it . ( Again there are some debates that the way we wrote the script is sequential and it is not useful for this testing ) However, When users increase i saw performance degrading a considerable rate for Temporary tables (when compared against procedure with EXEC IMMEDIATE) i was thinking it to be because of "insert" operation cost . is my understanding correct?
3) Only advantage with temp tables i saw is when you want to perform some logic instead of doing on entire data set, you can limit the scope of the data and insert into temporary table ( if dynamic filters we can use Exec ) and use it for further calculations which increases performance. In this case i saw a performance difference when i tried to use EXEC IMMEDIATE instead of EXEC to escape from creating Temporary Tables )
Below is one blog where i showed using EXEC IMMEDIATE but it was first designed using EXEC and Temporary table approach which we later changed to remove the usage of temporary tables.
SAP HANA: Handling Dynamic Select Column List and Multiple values in input parameter
Help me in understanding this "Temporary Tables" in a better way.
Regards,
Krishna Tangudu