Search code examples
temp-tablesgreenplum

Where do temporary tables get stored in a GreenPlum database?


In MS SQL Server Temporary tables are stored in tempdb Database.

Is there a similar special place in GreenPlum for temporary tables? Or is a temp table just stored in the current database & schema under which I do normal transactions?


Solution

  • Temporary tables in Greenplum are stored in the database in which they were created, but in a temporary schema which lives for the duration of the session which created the table.

    i.e.

    [gpadmin@mdw:~] $ createdb temp
    [gpadmin@mdw:~] $ psql temp
    temp=# create temporary table test_temp(a int) distributed by (a);
    CREATE TABLE
        Time: 50.516 ms
        temp=# \d
                         List of relations
           Schema   |   Name    | Type  |  Owner  | Storage
        ------------+-----------+-------+---------+---------
         pg_temp_11 | test_temp | table | gpadmin | heap
        (1 row)
    
    temp=# \dn
           List of schemas
            Name        |  Owner
    --------------------+---------
     gp_toolkit         | gpadmin
     information_schema | gpadmin
     pg_aoseg           | gpadmin
     pg_bitmapindex     | gpadmin
     pg_catalog         | gpadmin
     pg_temp_11         | gpadmin
     pg_toast           | gpadmin
     pg_toast_temp_11   | gpadmin
     public             | gpadmin
    (9 rows)
    
    temp=#
    
    temp=# \q
    
    [gpadmin@mdw:~] $ psql temp
    Timing is on.
    psql (8.3.23)
    Type "help" for help.
    
    temp=# \d
    No relations found.
    temp=# \dn
           List of schemas
            Name        |  Owner
    --------------------+---------
     gp_toolkit         | gpadmin
     information_schema | gpadmin
     pg_aoseg           | gpadmin
     pg_bitmapindex     | gpadmin
     pg_catalog         | gpadmin
     pg_toast           | gpadmin
     public             | gpadmin
    (7 rows)
    
    temp=#
    

    Does this answer your question?