Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQLServer2008-Multiple Import Process Simultaneous

Author  Topic 

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 12:55:03
I have a scenario where multiple users will be doing import processes, but all of them will be working for different clients.

I have one core table which gets the most hits whenever import processes run. I have 2 options now

To have one core table and do the sequential imports by making queue for the import processes.
To have 300 core table, one for each client, it will allow the users to work on the import processes simultaneously without waiting for one another.

Can anyone suggest which one is better and why?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 13:06:42
Tell us more about this import process for us to be able to suggest which option is better.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 13:15:47
More information about the import process:
1. This table is not going to be used in any Reporting.
2. Each import process process will insert 20k-30k records in this table.
3. This is going to be one of the most usable table in the application.

Please let me know if that helps and feel free to ask any specific question, if needed.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 13:17:31
How will the import be performed? BULK INSERT/bcp?

How many rows are in this table at any given time? What does the clustered index look like? Does it follow the import order? Have you considered table partitioning?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 13:40:47
It'll be BULK INSERT.
With each import, it will add around 20k rows in the table which is having 7 columns. And there will be around 20 imports a day.
Clustered index is on the Primary Key which is an Identity column.
Yes, I am considering the table partitioning too.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 13:52:28
Based upon what you've posted, I see no reason to separate it out. You'll need to confirm with a proper load test though.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 13:57:41
If we go with single table, then how will multiple users be able to load the data?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 14:06:42
They each would launch BULK INSERT.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 14:13:43
What if we use OPENXML instead of BULK INSERT, which option would be better in that case?

Secondly, if we go for BULK INSERT, we will also have some records that should be Updated instead of BULK INSERT. How those would be managed?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 14:22:37
Why do you need a different option? BULK INSERT is the way to go.

I don't understand your update question.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 14:31:17
Basically, what we are doing is, if we have 100 records in our file, we check for the existence of records in database; now if there are 60 new records and 40 old records. We make two separate OPENXMLs to insert and update in the table.

So, we have aforesaid scenario can we still use BULK INSERT for both insert and update operation?
Secondly, if we keep on filling in data in this single table, it would be too slower to retrieve the data from it which would affect the performance badly.
What you think about these two queries?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 14:35:07
BULK INSERT is only for inserts. If you have a requirement to update, then you'll need to either update the data before the BULK INSERT or BULK INSERT into a staging table, update the data, and then use T-SQL to move the data between tables.

I don't see that this import process is going to cause a problem for you. We have a multi-threaded system which does BULK INSERTs all day long and it's HUGE amounts of data (millions upon millions of rows per day). We have no issues querying this table.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 14:57:50
Thanks for making the point clear.

One thing, how do you manage the transformations while dong BULK INSERT?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 14:59:51
We don't need to transform the data. Our data is scrubbed ahead of time and imported as is.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 15:03:47
Can you give any specific suggestion regarding transformations while using BULK INSERT in my case?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 15:06:36
You can't transform data with BULK INSERT. You either scrub the data before the BULK INSERT or you BULK INSERT the data into a staging table and then transform it and then move it again.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 15:10:58
Scrub the data before the BULK INSERT is quicker than having a staging table, is that correct?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 15:13:09
I would think so, but your small data size should be okay either way. Only a load test can answer this though.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-17 : 15:18:46
Thanks for your help dear.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 15:23:35
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

imadiamond2016
Starting Member

29 Posts

Posted - 2011-08-19 : 14:08:01
Hi Tara

I have mentioned my requirement more clearly and detailed. Can you please once again have a close look and provide your comments.

Requirement:

The query is regarding data modeling for core functionality of my application.

I have a scenario where multiple users will be doing import processes, but all of them will be working for different clients. Also, at the same time client's data could be shown to the user and can be modified/inserted too, while the import process for the same or different client is in process.

I have 2 core tables which get the most hits whenever import processes run. I have 2 options now
1. To have 2 core tables and do the sequential imports by making queue for the import processes.

Table 1

ID
ClientID
SourceID
Count
AnotherCol1
AnotherCol2
AnotherCol3


Table 2

ID
ClientID
OrderID
Count
AnotherCol4
AnotherCol5
AnotherCol6

2. To have 1000 core table, 2 for each client (I may have maximum 500 clients), it will allow the users to work on the import processes simultaneously without waiting for one another.
More information about the import process:
1. These table is not going to be used in any Reporting.
2. Each import process will insert 20k-30k records (7 columns) in these each table. And there will be around 40-50 such imports in a day.
3. While the import process is going on, data could be retrieved from these tables by some other user and INSERT OR UPDATED too.
4. These are going to be one of the most usable tables in the application.
5. BULK INSERT will be used for insertion.
6. Clustered index is on the Primary Key which is an Identity column.
7. We are considering the table partitioning too.

Can you please suggest which option is better and why?

Also, if you suggest to go with option 2, then would it not be a performance hit to create so many tables in the database? Should we create a separate database for these 1000 tables in this case?
Go to Top of Page
    Next Page

- Advertisement -