I have a sproc that returns data from a table using a simple SELECT. There
are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the
rows, writing them out to a file. This takes about 5 minutes until I close
the reader.
Whilst this is going on, I have another application that is trying to insert
rows into the table. Normally, the inserts happen straight away, but when
the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am
trying to write to the table whilst reading from it, but the rows being
written will never be included in the WHERE clause in my select statement,
and even if they were (which they won't), I wouldn't want them included in
the selected rows.
Is there a way to read rows so that inserts can still occur without
blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles 18 1698
Charles,
Are the 2 applications on the same machine or different machines?
Is the database server on a different machine than the applications?
Kerry Moorman
"Charles Law" wrote:
I have a sproc that returns data from a table using a simple SELECT. There
are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the
rows, writing them out to a file. This takes about 5 minutes until I close
the reader.
Whilst this is going on, I have another application that is trying to insert
rows into the table. Normally, the inserts happen straight away, but when
the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am
trying to write to the table whilst reading from it, but the rows being
written will never be included in the WHERE clause in my select statement,
and even if they were (which they won't), I wouldn't want them included in
the selected rows.
Is there a way to read rows so that inserts can still occur without
blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
Charles,
You are by the way not using transaction locking, because then this is the
normal behaviour.
Cor
"Charles Law" <bl***@nowhere. comschreef in bericht
news:Om******** ******@TK2MSFTN GP06.phx.gbl...
>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through
the rows, writing them out to a file. This takes about 5 minutes until I
close the reader.
Whilst this is going on, I have another application that is trying to
insert rows into the table. Normally, the inserts happen straight away,
but when the reader is open each insert takes a very long time to
complete.
I realise that this is not an unreasonable thing to happen, given that I
am trying to write to the table whilst reading from it, but the rows being
written will never be included in the WHERE clause in my select statement,
and even if they were (which they won't), I wouldn't want them included in
the selected rows.
Is there a way to read rows so that inserts can still occur without
blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
On Thu, 19 Jun 2008 02:17:57 +0100, "Charles Law" <bl***@nowhere. com>
wrote:
>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the rows, writing them out to a file. This takes about 5 minutes until I close the reader.
Whilst this is going on, I have another application that is trying to insert rows into the table. Normally, the inserts happen straight away, but when the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am trying to write to the table whilst reading from it, but the rows being written will never be included in the WHERE clause in my select statement, and even if they were (which they won't), I wouldn't want them included in the selected rows.
Is there a way to read rows so that inserts can still occur without blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
You might take a look at the Transact-SQL statement SET TRANSACTION
ISOLATION LEVEL.
If the SELECT limits itself using a WHERE clause to rows which aren't in the inserted set, then you
have a chance to have the SELECT not blocked by your INSERTs. But that also depends on what
execution plan you get. If SQL Server drive the SELECT using an index which is on something that can
be used to exclude the rows to INSERT then you shouldn't see this blocking. However, considering you
return so many rows, you need to carefully evaluate your indexing strategy as well as your SELECT
query to make this happen.
Other options include Snapshot isolation and the READPAST optimizer hint. Those are well documented
in Books Online.
--
Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi
"Charles Law" <bl***@nowhere. comwrote in message news:Om******** ******@TK2MSFTN GP06.phx.gbl...
>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the rows, writing them
out to a file. This takes about 5 minutes until I close the reader.
Whilst this is going on, I have another application that is trying to insert rows into the table.
Normally, the inserts happen straight away, but when the reader is open each insert takes a very
long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am trying to write to the
table whilst reading from it, but the rows being written will never be included in the WHERE
clause in my select statement, and even if they were (which they won't), I wouldn't want them
included in the selected rows.
Is there a way to read rows so that inserts can still occur without blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
Hi Kerry
The two applications are on different machines, connected by a fairly slow
link, which is why it takes so long to iterate through the rows returned by
the reader. The database server is clustered on another machine, which is on
a Gb link to the second application, but the first (reader) application is
at the other end of the slow connection.
I could run both on the same machine, but then I would have to transfer the
resulting file over the slow link, and that would take longer in real time.
Charles
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:6A******** *************** ***********@mic rosoft.com...
Charles,
Are the 2 applications on the same machine or different machines?
Is the database server on a different machine than the applications?
Kerry Moorman
"Charles Law" wrote:
>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the rows, writing them out to a file. This takes about 5 minutes until I close the reader.
Whilst this is going on, I have another application that is trying to insert rows into the table. Normally, the inserts happen straight away, but when the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am trying to write to the table whilst reading from it, but the rows being written will never be included in the WHERE clause in my select statement, and even if they were (which they won't), I wouldn't want them included in the selected rows.
Is there a way to read rows so that inserts can still occur without blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
Hi Cor
No, I'm not explicitly using transaction locking. I thought, therefore, that
the reader would use row level locking, but if it is, it is still causing
some kind of locking problem.
Charles
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:1E******** *************** ***********@mic rosoft.com...
Charles,
You are by the way not using transaction locking, because then this is the
normal behaviour.
Cor
"Charles Law" <bl***@nowhere. comschreef in bericht
news:Om******** ******@TK2MSFTN GP06.phx.gbl...
>>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the rows, writing them out to a file. This takes about 5 minutes until I close the reader.
Whilst this is going on, I have another application that is trying to insert rows into the table. Normally, the inserts happen straight away, but when the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am trying to write to the table whilst reading from it, but the rows being written will never be included in the WHERE clause in my select statement, and even if they were (which they won't), I wouldn't want them included in the selected rows.
Is there a way to read rows so that inserts can still occur without blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
Hi Jack
I did read up about this, but it suggested that the default is row level
locking, which seemed to be the one I'd want anyway, so I haven't attempted
to change it. I have just looked again, and I see there is more to this than
I first thought, so I will read up.
Cheers
Charles
"Jack Jackson" <jj******@cinno vations.netwrot e in message
news:55******** *************** *********@4ax.c om...
On Thu, 19 Jun 2008 02:17:57 +0100, "Charles Law" <bl***@nowhere. com>
wrote:
>>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the rows, writing them out to a file. This takes about 5 minutes until I close the reader.
Whilst this is going on, I have another application that is trying to insert rows into the table. Normally, the inserts happen straight away, but when the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am trying to write to the table whilst reading from it, but the rows being written will never be included in the WHERE clause in my select statement, and even if they were (which they won't), I wouldn't want them included in the selected rows.
Is there a way to read rows so that inserts can still occur without blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
You might take a look at the Transact-SQL statement SET TRANSACTION
ISOLATION LEVEL.
Hi Tibor
Thanks for the reply. I hadn't thought about the indexing issue. I will add
these to my reading list.
Cheers
Charles
"Tibor Karaszi" <ti************ *************** @hotmail.nomail .comwrote in
message news:FC******** *************** ***********@mic rosoft.com...
If the SELECT limits itself using a WHERE clause to rows which aren't in
the inserted set, then you have a chance to have the SELECT not blocked by
your INSERTs. But that also depends on what execution plan you get. If SQL
Server drive the SELECT using an index which is on something that can be
used to exclude the rows to INSERT then you shouldn't see this blocking.
However, considering you return so many rows, you need to carefully
evaluate your indexing strategy as well as your SELECT query to make this
happen.
Other options include Snapshot isolation and the READPAST optimizer hint.
Those are well documented in Books Online.
--
Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi
"Charles Law" <bl***@nowhere. comwrote in message
news:Om******** ******@TK2MSFTN GP06.phx.gbl...
>>I have a sproc that returns data from a table using a simple SELECT. There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the rows, writing them out to a file. This takes about 5 minutes until I close the reader.
Whilst this is going on, I have another application that is trying to insert rows into the table. Normally, the inserts happen straight away, but when the reader is open each insert takes a very long time to complete.
I realise that this is not an unreasonable thing to happen, given that I am trying to write to the table whilst reading from it, but the rows being written will never be included in the WHERE clause in my select statement, and even if they were (which they won't), I wouldn't want them included in the selected rows.
Is there a way to read rows so that inserts can still occur without blocking?
I am using VB.NET in VS2005, and SQL Server 2005.
TIA
Charles
Charles Law wrote:
I have a sproc that returns data from a table using a simple SELECT.
There are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate
through the rows, writing them out to a file. This takes about 5
minutes until I close the reader.
If you are doing
while moreRecords
begin
read record
write record to file
end
then maybe the writing to disk is the slow step, so how about
while moreRecords
begin
read record
append record to stringbuilder
end
write stringbuilder to file
?
I take it getting the sp to write to a file is not an option?
Andrew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Ochs |
last post by:
I want to do a series of inserts within a single transaction block, but with
postgresql if one insert fails, the whole block is aborted. Is there any
way to get around this behavior so that postgresql won't abort the entire
transaction if a single insert returns an error?
Chris
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
|
by: Charles Law |
last post by:
I have a sproc that returns data from a table using a simple SELECT. There
are quite a few rows returned, e.g. ~150,000.
In my first application, I use a reader on the sproc and iterate through the
rows, writing them out to a file. This takes about 5 minutes until I close
the reader.
Whilst this is going on, I have another application that is trying to insert
rows into the table. Normally, the inserts happen straight away, but when...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |