December 21, 2007 at 5:47 am
I have one select query. Which is returning 1000 rows.It takes 20 min. But I dont want all rows simultaneously.
Is it possible that select query return row to screen as it is fetched.
December 21, 2007 at 5:54 am
are you using QA ? if 'yes' pls go to options -> results and check 'scroll results as received'
December 21, 2007 at 8:04 am
You could try the FAST n option for Select
For cursor....
SQL: sp_configure cursor threshold for SQL cursors can allow async fetch http://msdn2.microsoft.com/en-us/library/aa172570(SQL.80).aspx
EXEC sp_configure 'show advanced options',1 -- allow change of advanced options (BE CAREFUL)
RECONFIGURE WITH OVERRIDE
-- reconfigure 'cursor threshold' and force an asynch cursor
EXEC sp_configure 'cursor threshold', 100 -- Asynchronous for cursors > 100 rows
RECONFIGURE WITH OVERRIDE
-- do your async operations here
EXEC sp_configure 'cursor threshold', -1 -- Back to synchronous
RECONFIGURE WITH OVERRIDE
Toni
December 21, 2007 at 9:51 am
You could also try to split the query into multiples so you get an interim result set. This requires ordering the results so you get consistent output (also the TOP clause requires Order by).
The example below has the first query to get the first 10 rows and the second query then goes after the rest of the data (I set the second top nn to a number higher than the number of rows in the data).
You could repeat this multiple times to get more records each time. (get the next 10 not in the top 20... then the next 10 not in the top 30... and on and on).
use northwind
go
select top 10 with ties orderid,productid
from [order details]
order by orderid
select top 10000 with ties orderid,productid
from [order details]
where orderid not in
(select top 10 with ties orderid
from [order details]
order by orderid)
order by orderid
I think this is what you are looking for?
Toni
December 21, 2007 at 10:48 am
jitumevada (12/21/2007)
I have one select query. Which is returning 1000 rows.It takes 20 min. But I dont want all rows simultaneously.Is it possible that select query return row to screen as it is fetched.
The real problem is not returning rows early... the real problem is that the code takes 20 minutes to return only 1000 rows... My recommendation would be to fix the code to perform better... a lot better...
--Jeff Moden
Change is inevitable... Change for the better is not.
December 21, 2007 at 11:06 am
I agree 20 minutes for a thousand rows is a lot of time. If they would post the query, some data, schema information, etc then people could look to see if they could help speed the query itself. From what was asked for there is little to go on.
Toni
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy