title: PostgreSQL: How to clear a table with some columns in Toast table?
body: <p>When I use this command to clear a table (name is v_xml_cdr):</p>
  
  <pre><code>DELETE FROM v_xml_cdr;
  </code></pre>
  
  <p>then check table size with command \d+ ,but size of table v_xml_cdr is almost same as before.</p>
  
  <p>I searched in stackoverflow and learned it's because of the Toast table, some columns such as Text type use Extended storage, PostgreSQL treats them like a blob and use a toast table to store the actual data. </p>
  
  <pre><code>\d+ v_xml_cdr
  
                                           Table "public.v_xml_cdr”
           Column         |            Type             | Modifiers | Storage  | Stats target | Description 
  ------------------------+-----------------------------+-----------+----------+--------------+-------------
   uuid                   | uuid                        | not null  | plain    |              | 
   domain_uuid            | uuid                        |           | plain    |              | 
   extension_uuid         | uuid                        |           | plain    |              | 
   domain_name            | text                        |           | extended |              | 
   accountcode            | text                        |           | extended |              | 
   direction              | text                        |           | extended |              | 
  ...
  </code></pre>
  
  <p>Some people say that "vacuum full" command can shrink the table size after this problem happened.</p>
  
  <p>But I want to know if there's a good way to avoid this problem when clearing a table, other than using "vacuum full" command.</p>