IO_Dork
asked on
Database Query slow two databases
I have cyrstal reports that need to read from two different databases. Normally when my reports look at just one or the other database they read and return the records extremely fast. But when I connect to both in one report, record reading slows to a craw. What used to take a split second to run a portfolio holdings report now takes up to a minute or more. You can imagine if I have a grouped report pulling 100 or more accounts, this is not acceptable.
See the example below where I connect to both databases (FoxPro & CRM). Please note that this example is a little more complicated then my typical report that connects to both databases b/c i had a situation that required me to connect the "Trade" table in the CRM database to itself to pull related (linked) trades:
Also, link order and "link ordering is enforced"...how does that play into the speed of it all?
Version: CR-XI
Connections:
investor.iaccountid --> trade.iaccountid (inner join)
receiver.raccountid --> trade.raccountid (inner join)
trade.tradeid --> FilteredNew_trade_New.new_ tradenumbe r (left outer join)
FilteredNew_trade_New.new_ sourceid --> FilteredNew_trade_OLD.new_ tradeid (inner join)
Query:
Sterling Free Tables
SELECT `receiver`.`r_letter`, `receiver`.`r_address1`, `receiver`.`r_city`, `receiver`.`r_state`, `receiver`.`r_zip`, `receiver`.`raccountid`, `receiver`.`r_email`
FROM `receiver` `receiver`
WHERE `receiver`.`raccountid`='6 0343'
EXTERNAL JOIN receiver.raccountid={?Ster ling DBC: trade.raccountid}
Sterling DBC
SELECT `trade`.`aafsuffix`, `trade`.`iagentid`, `trade`.`settle_i`, `trade`.`prin_i`, `trade`.`basis_i`, `trade`.`days_i`, `trade`.`mdate_i`, `trade`.`rgross`, `trade`.`rnet`, `trade`.`cgross`, `trade`.`igross`, `trade`.`blocknum`, `trade`.`rbill`, `trade`.`cbill`, `trade`.`ibill`, `trade`.`icobbill`, `trade`.`rcobbill`, `trade`.`i_comment`, `trade`.`tradeid`, `trade`.`raccountid`, `trade`.`iaccountid`
FROM `trade` `trade`
WHERE `trade`.`raccountid`={?Ste rling Free Tables: receiver.raccountid} AND `trade`.`mdate_i`>{d '2013-09-19'} AND `trade`.`settle_i`<={d '2013-09-19'} AND NOT (`trade`.`rcobbill`='B' OR `trade`.`rcobbill`='P') AND NOT (`trade`.`i_comment` LIKE 'non uss' OR `trade`.`i_comment` LIKE 'Non-uss')
EXTERNAL JOIN trade.iaccountid={?Sterlin g Free Tables: investor.iaccountid} AND trade.tradeid={?uss_crm: FilteredNew_trade_New.new_ tradenumbe r}
Sterling Free Tables
SELECT `investor`.`i_letter1`, `investor`.`i_city`, `investor`.`i_state`, `investor`.`iaccountid`
FROM `investor` `investor`
WHERE `investor`.`iaccountid`={? Sterling DBC: trade.iaccountid}
uss_crm
SELECT "FilteredNew_trade_New"."n ew_sourcei d", "FilteredNew_trade_OLD"."n ew_settleo n", "FilteredNew_trade_OLD"."n ew_days", "FilteredNew_trade_OLD"."n ew_bcgross rate", "FilteredNew_trade_OLD"."n ew_brname" , "FilteredNew_trade_OLD"."n ew_brnetra te", "FilteredNew_trade_New"."n ew_tradenu mber"
FROM "crm_MSCRM"."dbo"."Filtere dNew_trade " "FilteredNew_trade_New" INNER JOIN "crm_MSCRM"."dbo"."Filtere dNew_trade " "FilteredNew_trade_OLD" ON "FilteredNew_trade_New"."n ew_sourcei d"="Filter edNew_trad e_OLD"."ne w_tradeid"
WHERE "FilteredNew_trade_New"."n ew_tradenu mber"={?St erling DBC: trade.tradeid}
See the example below where I connect to both databases (FoxPro & CRM). Please note that this example is a little more complicated then my typical report that connects to both databases b/c i had a situation that required me to connect the "Trade" table in the CRM database to itself to pull related (linked) trades:
Also, link order and "link ordering is enforced"...how does that play into the speed of it all?
Version: CR-XI
Connections:
investor.iaccountid --> trade.iaccountid (inner join)
receiver.raccountid --> trade.raccountid (inner join)
trade.tradeid --> FilteredNew_trade_New.new_
FilteredNew_trade_New.new_
Query:
Sterling Free Tables
SELECT `receiver`.`r_letter`, `receiver`.`r_address1`, `receiver`.`r_city`, `receiver`.`r_state`, `receiver`.`r_zip`, `receiver`.`raccountid`, `receiver`.`r_email`
FROM `receiver` `receiver`
WHERE `receiver`.`raccountid`='6
EXTERNAL JOIN receiver.raccountid={?Ster
Sterling DBC
SELECT `trade`.`aafsuffix`, `trade`.`iagentid`, `trade`.`settle_i`, `trade`.`prin_i`, `trade`.`basis_i`, `trade`.`days_i`, `trade`.`mdate_i`, `trade`.`rgross`, `trade`.`rnet`, `trade`.`cgross`, `trade`.`igross`, `trade`.`blocknum`, `trade`.`rbill`, `trade`.`cbill`, `trade`.`ibill`, `trade`.`icobbill`, `trade`.`rcobbill`, `trade`.`i_comment`, `trade`.`tradeid`, `trade`.`raccountid`, `trade`.`iaccountid`
FROM `trade` `trade`
WHERE `trade`.`raccountid`={?Ste
EXTERNAL JOIN trade.iaccountid={?Sterlin
Sterling Free Tables
SELECT `investor`.`i_letter1`, `investor`.`i_city`, `investor`.`i_state`, `investor`.`iaccountid`
FROM `investor` `investor`
WHERE `investor`.`iaccountid`={?
uss_crm
SELECT "FilteredNew_trade_New"."n
FROM "crm_MSCRM"."dbo"."Filtere
WHERE "FilteredNew_trade_New"."n
ASKER
Subreports... I don't know, I guess I'd have to sort that out/figure that out and try it.
On the other recommendation:
So you're suggesting using a third source like access to fool Crystal Reports in thinking that it's only connecting to one database, correct? I guess I could try that too, I'll just have to figure out how to do that.
Thirdly, should I be looking at other reporting software that would handle this duel database situation better? Any suggestions or recommendations if there are any?
On the other recommendation:
So you're suggesting using a third source like access to fool Crystal Reports in thinking that it's only connecting to one database, correct? I guess I could try that too, I'll just have to figure out how to do that.
Thirdly, should I be looking at other reporting software that would handle this duel database situation better? Any suggestions or recommendations if there are any?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
One is SQL I believe ( microsoft crm) and the other is the old and crusty foxpro.
ASKER
does linking a database like ms crm cause any disruption in the performance or is it really just passive link to the other database. I don't want to do anything that will be to invasive or put a drag on the performance of either database and the front ends that are used to interface with them.
The link is passive and data is only requested when a query runs that needs it.
mlmcc
mlmcc
The problem is all the data is being brought to the PC for filtering, sorting, and grouping. With a single data source that is handle on the very fast server.
Is it possible to use one source for the main report and use the other for a subreport?
Can you set up one source and link it to the other or use MS Access to link to both sources and pull from there?
mlmcc