title: Alter Table Set Statistics requires table lock
body: <p>I have run into a case such that Pg always preferring into a sequential scan for a table that has around 70M rows. (Index scan is ideal for that query and i have confirmed it by setting enable_seq_scan=off, speed improved by 200x)</p>
  
  <p>So, in order to help Pg understand my data better i executed this   </p>
  
  <p><code>ALTER TABLE tablename ALTER COLUMN columnname SET STATISTICS 1000;</code>  </p>
  
  <p>Unfortunately this requires <a href="https://www.postgresql.org/docs/9.4/static/sql-altertable.html" rel="nofollow noreferrer">Update Exclusive lock</a> which locks the entire table (too much lock).</p>
  
  <ol>
  <li>Is there a solution to avoid locking for this statement ?  </li>
  <li>Data sharding is done for this table based on Primary Key Range, so I would like Pg to even understand my Pk better so that it knows which User has got large data. Will it be of use if i increase the statistics of PrimaryKey column as well ?</li>
  </ol>