Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

File Upload - Storing into a Database - Efficiency

721872Jul 27 2010 — edited Aug 3 2010
Hello All:

I am taking a file upload and storing it into an Oracle database. The process works fine, but when I get a larger file (4 - 5MB), it takes a VERY long time to save to the database. I am not really having a bottleneck in the .Net portion, it is the saving into the database that takes 15 minutes to load and this seems like a very long time and not sure if there is something I am doing wrong, something on the database I can tweak or this is just normal processing and we have to live with it.

But here is the code and wondered if anyone notices something I am doing wrong:

Code Behind File (takes no time at all to process):

//-------------------------------------------------------------------------
// If a OnePager has been uploaded, get the filename and document bytes
//-------------------------------------------------------------------------

if (fuOnePagerDocument.HasFile)
{
byte[] onePager = new
byte[fuOnePagerDocument.PostedFile.InputStream.Length];
fuOnePagerDocument.PostedFile.InputStream.Read(onePager, 0, onePager.Length);
project.OnePager = onePager;
project.OnePagerFileName = System.IO.Path.GetFileName(fuOnePagerDocument.PostedFile.FileName);
} //if(fuOnePagerDocument.HasFile)

I then take all of the data on the form, send it to the business layer for processing (ensure the data is correct, secure, etc) and send it to the data layer as the business layer itself processes in no time as well and there really isn't any code that relates to the file so I am not posting any.

DataLayer (when I hit the ExecuteNonQuery, it takes 15 minutes for a large file, but for small files, processes fairly quickly, I also do more with this transaction, but that part runs with no problems, this is the part with the bottleneck......):

//-----------------------------------------------------------------------------
// Variable Declarations
//-----------------------------------------------------------------------------
OracleConnection oConn = null;
Boolean retValue = true;
int projectID = 0;
string groupID = String.Empty;
oConn = new OracleConnection(ConfigurationManager.ConnectionStrings["PaySol"].ConnectionString);
oConn.Open();
OracleTransaction projectTransaction = oConn.BeginTransaction();
try
{
//-------------------------------------------------------------------------
// Create the Projects Command
//-------------------------------------------------------------------------
OracleCommand projects = oConn.CreateCommand();
projects.CommandText = "sp_ProjectSaveWithConcept";
projects.CommandType = CommandType.StoredProcedure;
projects.Transaction = projectTransaction;
.
.
.
//-------------------------------------------------------------------------
// Check for a Null OnePager
//-------------------------------------------------------------------------
if(project.OnePager == null)
projects.Parameters.Add("onePager_", OracleDbType.Blob).Value = System.DBNull.Value;
else
projects.Parameters.Add("onePager_",
OracleDbType.Blob).Value = project.OnePager;
//-------------------------------------------------------------------------
// Check for a Null OnePagerFileName
//-------------------------------------------------------------------------
if(project.OnePagerFileName == null)
projects.Parameters.Add("onePagerFileName_", OracleDbType.Varchar2).Value = System.DBNull.Value;
else
projects.Parameters.Add("onePagerFileName_", OracleDbType.Varchar2).Value = project.OnePagerFileName;
//-------------------------------------------------------------------------
// Execute the Projects Stored Procedure
//-------------------------------------------------------------------------
projects.ExecuteNonQuery();
projectID = Convert.ToInt32(projects.Parameters["projectIDOut_"].Value.ToString());
}

My stored procedure is a basic stored procedure. I simply pass in the values (the OnePager is of type BLOB), then if there is no projectID, I do an insert, and if there is a projectID passed in, I do an update and return the projectID. Nothing really fancy inside it, but this .ExecuteNonQuery is where the bottleneck is occurring. Is there something I am missing, could set a property someplace in the code or database to speed this up?

If you need to see the stored procedure for anything, let me know. I just didn't think it was relevant for anything.

Thanks,
Andy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2010
Added on Jul 27 2010
8 comments
1,616 views