title: Huge performance difference between Vector and HashSet
body: <p>I have a program which fetches records from database (using Hibernate) and fills them in a <code>Vector</code>. There was an issue regarding the performance of the operation and I did a test with the <code>Vector</code> replaced by a <code>HashSet</code>. With 300000 records, the speed gain is immense - 45 mins to 2 mins! </p>
  
  <p>So my question is, what is causing this huge difference? Is it just the point that all methods in <code>Vector</code> are synchronized or the point that internally <code>Vector</code> uses an array whereas <code>HashSet</code> does not? Or something else?</p>
  
  <p>The code is running in a single thread.</p>
  
  <p><em>EDIT</em>:
  The code is only inserting the values in the <code>Vector</code> (and in the other case, <code>HashSet</code>).</p>