Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Report runs slow but... Post Reply Post New Topic
Author Message
Elena
Newbie
Newbie


Joined: 16 Apr 2008
Location: United States
Online Status: Offline
Posts: 10
Quote Elena Replybullet Topic: Report runs slow but...
     Posted: 16 Dec 2011 at 5:39am
My report runs for 8 minutes. It has SQL like this: SELECT * FROM tblCustomers
However it runs just 3 seconds when I divide it to 2:
SELECT * FROM tblCustomers WHERE CustomerID<='500000'
UNION ALL
SELECT * FROM tblCustomers WHERE CustomerID > '500000'
This table tblCustomer has about 1 million records.
Table located on SQL Server 2008. I think it is not enough memory.
When I worked with ORACLE database I had a message:"increase segment".
How can I increase memory space on SQL Server? Or it is another reason?
(actual SQL is more complex)
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 Dec 2011 at 5:39am
I don't have an answer, but a question...
 
why do you need to load all 1 million+ records?
 
more than likely they won't be printed, they won't be selected from as lists are limited to something like 1000 records, if there are 1 million customers that would imply a report with so many pages that no one would read it...exporting to excel prior to the current version of CR would fail as well as that has a limit of 64000 records (more or less).
 
so with that in mind, is there a way to limit the number of records that you really need to access?
 
just wondering.
IP IP Logged
Elena
Newbie
Newbie


Joined: 16 Apr 2008
Location: United States
Online Status: Offline
Posts: 10
Quote Elena Replybullet Posted: 04 Jan 2012 at 4:32am
My Query returns just about 20 records. But I need to use a table with 1 million records to calculate what I need.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 04 Jan 2012 at 5:26am
ok. that's a reasonable answer (i've seen posts for pulling in 5 million records for the report)
well, it probably isn't sql server, since it would still be holding 1 million records in memory as a temp table (I would check if the speed difference is in SQL server by running the query or just in CR trying to process the output).
 
if it's not SQL Server(and I'll bet it isn't...though it will take a long time to display a million records, it will load it into a temp table is seconds) and you can create a stored proc (or maybe a view) I would try that route and let SQL Server filter your recordset instead of CR.
 
Standard statement...let SQL deal with the large sets of data, it's designed to that, tends to be on a more powerful box.  Let CR deal with the display of the record set, and not the filtering of the data.
 
I do realize that not all report writers have the ability to create stored proc (either because they haven't done that before or because they don't have rights to), but when you can, I think that it is the way to go.
IP IP Logged
Elena
Newbie
Newbie


Joined: 16 Apr 2008
Location: United States
Online Status: Offline
Posts: 10
Quote Elena Replybullet Posted: 04 Jan 2012 at 6:10am
My Stored Procedure runs slow from SQL Server Management Studio. But when I separate it in 2 peaces using UNION ALL statement - it runs fast. I think that something is wrong with SQL Server Memory.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 04 Jan 2012 at 8:04am
hmmm...
Interesting.
 
The only other thought is to add an index for the stored proc...which again is not always possible. 
 
Quite frequently, I use temp tables, and so I can create indices for them...or sometimes the DBA creates them on the main table, but he is not always inclined to do so.
 
Either way it is odd, since SQL Server is holding the results of a million records, but if you have complex sql that filters the data at the same time, perhaps SQL Server is not actually holding a million records, though it would still be scanning the table...
 
well maybe the index will help, otherwise you got me.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum