title: PostgreSQL error cache lookup failed for relation - what causes it and why?
body: <p>I have a query that is erroring out when attempting to create a temporary table. The query is:</p>
  
  <blockquote>
    <p>CREATE TEMPORARY TABLE temp_table_t (LIKE original_table INCLUDING INDEXES)</p>
  </blockquote>
  
  <p>The error being returned is:</p>
  
  <blockquote>
    <p>postgres7 error: [-1: ERROR:  cache lookup failed for relation 14026125] in EXECUTE("CREATE TEMPORARY TABLE temp_table_t (LIKE original_table INCLUDING INDEXES)")</p>
  </blockquote>
  
  <p>I found two threads on the PostgreSQL forums but they didn't explain much, unfortunately:</p>
  
  <p><a href="http://archives.postgresql.org/pgsql-performance/2010-04/msg00026.php" rel="noreferrer">http://archives.postgresql.org/pgsql-performance/2010-04/msg00026.php</a></p>
  
  <p><a href="http://archives.postgresql.org/pgsql-performance/2010-04/msg00028.php" rel="noreferrer">http://archives.postgresql.org/pgsql-performance/2010-04/msg00028.php</a></p>
  
  <p>This query runs on other servers just fine, it is failing specifically on only one of our servers. Is there any insight you can give me as to what is causing the error and how to fix it? I first thought that it was the result of creating a temporary table name with the same name of an existing temporary table. I updated my code to create a randomly named temporary table each time, and that did not work either.</p>