Memory usage - Temp Table

  • I would like to know the memory usage of a temporary table while a procedure is running.

    Scenario:

    create procedure p1

    (

    @AssetID varchar(max)

    )

    as

    begin

    create table #t1

    (

    AssetID INT

    )

    insert into #t1

    SELECT LTRIM(RTRIM([Value])) FROM dbo.fnSplitToRow(@AssetID, ',')

    <other logics>

    end

    UI will pass the value with comma seperated value.

    say for example

    1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

    Above values will be transposed into row and then stored in #t1 table.

    I would like to know how much of space #t will take from temp database to store these values.

    Because I am going to use 'Tally' table to split the comma seperated values. so that i have to send a report to my manager like 'this much of amount have been saved after implementing 'Tally' table'

    Inputs are welcome!

    karthik

  • Its an INT column where u are going to stuff your final output!

    INT takes 4 bytes of space regardless of the "number" present in the row!

    So assuming, after your operation is over and u have 1 million records, then the disk space used id

    1 million * 4 bytes = 4000000 bytes = 38 MB ~ 40 MB! I have not used the calculator, so the value is approximate only!

    Hope this helps!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply