title: Primary Key assignment in Postgres
body: <p>I have table <code>tmp</code> in my postgres database that contains roughly 139 million records.  I am trying to move the the columns <code>col1</code>, <code>col2</code>, and <code>col3</code> to <code>col1</code>, <code>col2</code>, and <code>col3</code> of another tabled named <code>r4a</code>. I created the table <code>r4a</code> with this query:</p>
  
  <pre><code>CREATE TABLE r4a(
      gid serial NOT NULL,
      col1 double precision,
      col2 double precision,
      col3 double precision,
      the_geom geometry,
      CONSTRAINT r4a_pkey PRIMARY KEY (gid));
  </code></pre>
  
  <p>I created this insert into query to populate fields in <code>r4a</code>:</p>
  
  <pre><code>INSERT INTO r4a (col1,col2,col3)
  SELECT col1, col2, col3
  FROM tmp
  limit 500;
  </code></pre>
  
  <p>It populates the <code>gid [PK] serial</code> column with numbers ranging from [14816024-14816523].  </p>
  
  <p>How does it determine which 500 records to limit the query too?<br>
  Is it choosing to import rows [14816024-14816523] or is it just arbitrarily assigning numbers?</p>
  
  <p>Ideally I want the primary key to begin at 1 and count upwards.  Being new to postgres and having such a large (in my opinion) table, I want to make sure I understand what is going on.</p>