Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Command Add slows performance Post Reply Post New Topic
Author Message
pellis
Newbie
Newbie


Joined: 09 Mar 2008
Online Status: Offline
Posts: 14
Quote pellis Replybullet Topic: Command Add slows performance
     Posted: 28 Apr 2008 at 11:00am
Hello,
I have created a report that uses 10 Command Add statements.  I did this because the 10 data fields that I needed were all in one memo data field and this was the only way I could extract what I needed.  This has slowed down processing of the report significantly.  To process about 5,000 records takes about 5 minutes. Any suggestions on how to speed up processing time.
 
Any help is greatly appreciated.
 
pellis


Edited by pellis - 28 Apr 2008 at 11:02am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Apr 2008 at 12:51pm
Can you make it into a single stored procedure? This pushes all the data processing down to the database server and takes the load off of Crystal.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
pellis
Newbie
Newbie


Joined: 09 Mar 2008
Online Status: Offline
Posts: 14
Quote pellis Replybullet Posted: 28 Apr 2008 at 2:27pm
Thanks so much for replying. I'll try that.  I get confused when trying to write a sql statement that will select different data from the same data memo field.  Here is what I'm trying to do.
   There is a database table called Profile_value which contains three fields; uid(user id), fid(field ID) and value(a value depending on the fid)
I need to extract data for fname, lname, gender,birthday, state, zip, etc.
    Here is how that data is idenfified.
Profile_values.fid = 1  then profile_values.Value = fname
Profile_values.fid = 2  then profile_values.value = lname
Profile_values.fid = 3 then profile_values.value = gender 
 
This is joined with a table called User which is joined on the uid field.
 
Here is how I wrote the add command for each peice of data.
     select uid,fid, cast(value as char (20)) as 'Fname'
     from profile_values
     where profile_values.fid =1      ,   etc.
 
Not sure how to accomplish this using a stored procedure because I would be using the same select statement over and over and assigning a new name to value depending on the fid number.   Can you give me a couple of lines of sql statment that will accomplish this in a stored procedure?  All help is greatly appreciated and thanks so much in advance.
 
Pattyg   
 
IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 29 Apr 2008 at 9:08am
you might be able to do this in the same SQL statement by using a left outer join. Join all the sql satement using UID field. You can have a main sql statement which gets all the values for uid and then join all other SQL statement to that using uid.
 
SELECT a.UID, a.fid, b.fname , c.lname, d.gender
FROM a as profile_value as a
LEFT OUTER JOIN
(SELECT uid,fid, cast(value as char (20)) as 'Fname'
     FROM profile_values
     WHERE profile_values.fid =1) as b
ONa.UID = b.UID
LEFT OUTER JOIN
(SELECT uid,fid, cast(value as char (20)) as 'lname'
    FROM profile_values
     WHERE profile_values.fid =2) as c
ON a.UID = c.UID
LEFT OUTER JOIN
(SELECT uid,fid, cast(value as char (20)) as 'gender'
    FROM profile_values
     WHERE profile_values.fid =3) as d
 
This should work for you. make changes to sql as needed. This is the way to go when you have different conditions on the same field
 
Hope this helps. Brian will probably give you a better idea on this
 
 
IP IP Logged
pellis
Newbie
Newbie


Joined: 09 Mar 2008
Online Status: Offline
Posts: 14
Quote pellis Replybullet Posted: 29 Apr 2008 at 2:29pm
Thanks so much for your help.  I did use the sql statments that you suggested but I keep getting this error msg.
 
Failed to retrieve data from database.
Details:42000:[ySQL][ODBC 3.51Driver][mysqld-5.0.51-community-nt] you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 24
[Database Vendor Code:1064]
 
Here is the sql statement.
 
SELECT a.UID, a.fid, b.fname , c.lname, d.gender,e.city,f.state
FROM a as profile_value
LEFT OUTER JOIN
(SELECT uid,fid, cast(value as char (20)) as 'Fname'
     FROM profile_values
     WHERE profile_values.fid =1) as b
ON a.UID = b.UID
LEFT OUTER JOIN
(SELECT uid,fid, cast(value as char (20)) as 'lname'
    FROM profile_values
     WHERE profile_values.fid =2) as c
ON a.UID = c.UID
LEFT OUTER JOIN
(SELECT uid,fid, cast(value as char (20)) as 'gender'
    FROM profile_values
     WHERE profile_values.fid =3) as d
LEFT outer join
(SELECT uid,fid,cast(value as char(20)) as 'city'
   FROM profile_values
   WHERE profile_values.fid=16) as e
left outer join
(SELECT uid,fid, cast(value as char(20)) as  ' state'
  FROM profile_values
  WHERE profile_values.fid=17) as f
 
I am currently trying to figure out how to resolve this issue.  Have any of you guys run into this problem before?   Thanks.
IP IP Logged
pellis
Newbie
Newbie


Joined: 09 Mar 2008
Online Status: Offline
Posts: 14
Quote pellis Replybullet Posted: 01 May 2008 at 9:20am
Fusion,
Thanks so much for your help.  I did get the sql statements to work after I fiddled around with them for a while.  I really appreciate your help.  Thanks again.
IP IP Logged
invaderjim
Newbie
Newbie


Joined: 08 Oct 2008
Online Status: Offline
Posts: 1
Quote invaderjim Replybullet Posted: 08 Oct 2008 at 6:24am
pellis -

I've encountered the same MySQL error code (1064) with a query I'm trying to use in CR, and I was wondering what sort of fiddling you had to do to get your query to work.

Thanks.
IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 10 Oct 2008 at 12:57pm
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