473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Database strategy in a multithreaded app.

Hello,

I am writing a server that will be inserting/reading/updating the
database on multiple threads. I understand that you can't have more
than 1 reader open on a database connection. Are there any other
limitations? Like can I have more than one command object inserting on
the same connection? Any other pitfalls, I should look out for?

Thanks.
Nov 16 '05 #1
6 1751
Frank Rizzo <no****@nospam.com> wrote:
I am writing a server that will be inserting/reading/updating the
database on multiple threads. I understand that you can't have more
than 1 reader open on a database connection. Are there any other
limitations? Like can I have more than one command object inserting on
the same connection? Any other pitfalls, I should look out for?


Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Frank,

I am curious what is your goal with this.

The client is accessing a single thread of updating.
It can not read in that time inside one table because it does not know the
concurrency situation and with more tables it has to handle relations.

The connection is accessing over the network or over internet. However it is
one line, you cannot sinful optimize it by using more connections when it
would be to slow what is the normal reason for multithreading here. (Just
give more priority on that line when it is dealt with others)

The database is accessing at full speed the given commands from the clients
one by one and needs as well concurrency synchronization. (However even
without that and with completly unrelated datatables can it only handle one
thing at time)

I am really interested what you want to achieve and than how you would
handle your dependencies.

Cor
Nov 16 '05 #3
Jon Skeet [C# MVP] wrote:
Frank Rizzo <no****@nospam.com> wrote:
I am writing a server that will be inserting/reading/updating the
database on multiple threads. I understand that you can't have more
than 1 reader open on a database connection. Are there any other
limitations? Like can I have more than one command object inserting on
the same connection? Any other pitfalls, I should look out for?

Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.


Would the application not be slowed down by constant opening/reopening
of the connection?

Nov 16 '05 #4
Cor Ligthert wrote:
Frank,

I am curious what is your goal with this.

The client is accessing a single thread of updating.
It can not read in that time inside one table because it does not know the
concurrency situation and with more tables it has to handle relations.
That's not true, depending on the locking mechanism you can select and
insert at the same time. In my database design, there are very little
concurrency issues. In other words, the clients access a different set
of data - never the same.

The connection is accessing over the network or over internet. However it is
one line, you cannot sinful optimize it by using more connections when it
would be to slow what is the normal reason for multithreading here. (Just
give more priority on that line when it is dealt with others)
Yes, you can, because the bandwidth needed for the commands to the
database is very low. The work is mostly done at either the client
level or the database level.
The database is accessing at full speed the given commands from the clients
one by one and needs as well concurrency synchronization. (However even
without that and with completly unrelated datatables can it only handle one
thing at time).
That's true and that's ok. I can optimize at the database level by
storing all indexes on a different drive, for instance. This way
physical I/O can work in parallel (sometimes). And, of course, you can
always throw more money at the machine.
I am really interested what you want to achieve and than how you would
handle your dependencies.


I am looking for robustness first, speed second. Mostly because you can
buy speed. You can't buy robustness.
Nov 16 '05 #5
Frank Rizzo <no**@none.com> wrote:
Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.


Would the application not be slowed down by constant opening/reopening
of the connection?


No - it doesn't close the physical connection, it just returns it to
the pool.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
Jon Skeet [C# MVP] wrote:
Frank Rizzo <no**@none.com> wrote:
Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.


Would the application not be slowed down by constant opening/reopening
of the connection?

No - it doesn't close the physical connection, it just returns it to
the pool.

Thank you very much.
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Eric S. Johansson | last post by:
I have an application where I need a very simple database, effectively a very large dictionary. The very large dictionary must be accessed from multiple processes simultaneously. I need to be...
1
by: peter wang | last post by:
Hi, Could anyone tell me the backup strategy for a 1000GB database? Thank you! Peter Wang *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in...
2
by: pradyumna | last post by:
In Project settins - C/C++ - Code Generation, what is the difference between the option "Multithreaded" and "Multithreaded DLL". I understand that on selecting multithreaded option, single and...
19
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested...
2
by: Alan Kemp | last post by:
Hi, I have a problem that is half python, half design. I have a multithreaded network server working, each client request spawns a new thread which deals with that client for as long as it is...
0
by: Takpol | last post by:
Greetings Group Members, I am going to implement a strategy for archiving and restoring old filegroups. Part of my data has been stored in date partitioned files and filegroups. So the archive...
6
by: Stephen Carson | last post by:
I'm trying to build a Web Service that will kick off threads as logging requests come in. These threads will then log to the database. I have been able to make a simple Web Service. I have been...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
2
by: Steve | last post by:
I have been asked to convert an Access2002 database to Access2007. The database is used to manage a medium sized company. The company contact said that the existing database was put on a new...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.