title: Timeout when uploading images
body: <p>I am currently testing Tridion 2011 and am having problems creating multimedia components with uploaded content (as opposed to external).</p>
  <p>I fill out the title, schema, multimedia type, select a file from my system then click save. I get a <code>Saving item...</code> information message then approximately 30 seconds later I will receive a <code>The wait operation timed out</code> message.</p>
  <p>There doesn't appear to be any error messages in the <code>C:\Program Files (x86)\Tridion\log</code> directory. Looking at the event viewer I see the following information relating to the save action</p>
  <pre><code>Unable to save Component (tcm:4-738361).
  The wait operation timed out
  
  Error Code:
  0x8004033F (-2147220673)
  
  Call stack:
  System.Data.SqlClient.SqlConnection.OnError(SqlException,Boolean,Action`1)
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException,Boolean,Action`1)
  System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject,Boolean,Boolean)
  System.Data.SqlClient.TdsParser.TryRun(RunBehavior,SqlCommand,SqlDataReader,BulkCopySimpleResultSet,TdsParserStateObject,Boolean&amp;)
  System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader,RunBehavior,String)
  System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior,RunBehavior,Boolean,Boolean,Int32,Task&amp;,Boolean)
  System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior,RunBehavior,Boolean,String,TaskCompletionSource`1,Int32,Task&amp;,Boolean)
  System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1,String,Boolean,Int32,Boolean)
  System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
  Tridion.ContentManager.Data.AdoNet.Sql.SqlDatabaseUtilities.SetBinaryContent(Int32,Stream)
  Tridion.ContentManager.Data.AdoNet.ContentManagement.ItemDataMapper.Tridion.ContentManager.Data.ContentManagement.IItemDataMapper.SetBinaryContent(Stream,TcmUri)
  Tridion.ContentManager.ContentManagement.RepositoryLocalObject.SetBinaryContent(BinaryContent)
  Tridion.ContentManager.ContentManagement.Component.OnSaved(SaveEventArgs)
  Tridion.ContentManager.IdentifiableObject.Save(SaveEventArgs)
  Tridion.ContentManager.ContentManagement.VersionedItem.Save(Boolean)
  Tridion.ContentManager.ContentManagement.VersionedItem.Save()
  Tridion.ContentManager.BLFacade.ContentManagement.VersionedItemFacade.UpdateAndCheckIn(UserContext,String,Boolean,Boolean)
  XMLState.Save
  Component.Save
  </code></pre>
  <p>I already have my timeout settings in the Content Manager Snap-In set to high values (more than 10 minutes) due to <a href="https://stackoverflow.com/questions/12316052/tridion-event-system-timeout">another issue</a>.</p>
  <p>The <code>BINARIES</code> table in the Content Manage Database is 25GB if that helps.</p>
  <p>Any ideas? Thanks.</p>
  <h2>Edit 1</h2>
  <p>Following suggestions from Bart Koopman, my DBA has rebuilt the indexes but does not reckon the Transaction log has any impact on performance. The problem persists.</p>
  <h2>Edit 2</h2>
  <p>I have just found more details of the error</p>
  <pre><code>Unable to save Component (tcm:0-0-0).
  Timeout expired.
  The timeout period elapsed prior to completion of the operation or the server is not responding.
  A database error occurred while executing Stored Procedure &quot;EDA_ITEMS_UPDATEBINARYCONTENT&quot;.EDA_ITEMS_UPDATEBINARYCONTENT
  </code></pre>
  <p>After taking a look at this procedure it looks like the following statement could be the root cause</p>
  <pre><code>SELECT 1 FROM BINARIES WHERE ID = @iBINARY_ID AND CONTENT IS NULL
  </code></pre>
  <p>I execute it manually with @iBINARY_ID as -1 and after 2 minutes it still hasn't completed. I assume that when I insert a new multimedia component the query will be something similar (i.e. the id will not exist in the table).</p>
  <p>The BINARIES table currently has a <code>NON-CLUSTERED</code> Primary Key. Maybe the solution would be to change this to a <code>CLUSTERED </code>Primary Key? However, I assume it is NON-CLUSTERED for a reason.</p>