Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any way to speed this select?
Message
 
 
À
26/05/2006 09:56:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01125229
Message ID:
01125262
Vues:
13
>Sure it is slower over the network. But is it faster, or slower, if you divide the query into pieces?
>
>Also, make sure you have the relevant indices.

I think it's even slower. For local database it's faster, for network database it's slower. Here is the procedure I've tried (and now I switched back to the original for the network db):
************************************************************
*  PROCEDURE GetEmployeesQueuesInfo()
************************************************************
*  Author............: Nadya Nosonovsky
*  Project...........: Visual Collections
*  Created...........: 06/16/2005  16:46:12
*  Copyright.........: (c) Jzanus, 2005
*) Description.......:
*  Calling Samples...:
*  Parameter List....:
*  Major change list.:
procedure GetEmployeesQueuesInfo
lparameters tdDate, tcAlias
local ltTime

if empty(m.tcAlias)
	tcAlias = 'c_EmployeesQueuesInfo'
endif

if empty(m.tdDate)
	tdDate = date()
endif

ltTime = dtot(m.tdDate + 1)-1
if not used('Trans')
	use MMVisCollect!trans in 0 again alias trans
endif
if not used('Trans_Employees_Queues')
	use MMVisCollect!Trans_Employees_Queues in 0 ;
	again alias Trans_Employees_Queues
endif
if not used('Employee_Queue_Schedules')
	use MMVisCollect!Employee_Queue_Schedules in 0 ;
	again alias Employee_Queue_Schedules
endif

select cTrans_Employees_Queues_fk ;
    from Employee_Queue_Schedules EQS ;
    where EQS.tScheduled_time <= m.ltTime and EQS.iActive_Flag = 1 ;
    into cursor curFirst

select TEQ.cTrans_fk, ;
	TEQ.cCommission_Owner_UsGrLink_fk as cUsGrLink_pk from  ;
	Trans_Employees_Queues TEQ ;
	inner join curFirst ;
	on TEQ.cTrans_Employees_Queues_pk = curFirst.cTrans_Employees_Queues_fk ;
	where TEQ.iActive_Flag = 1 ;
union all ;
 select TEQ.cTrans_fk, ;
	TEQ.cUsGrLink_fk as cUsGrLink_pk from  ;
	Trans_Employees_Queues TEQ ;
	inner join curFirst ;
	on TEQ.cTrans_Employees_Queues_pk = curFirst.cTrans_Employees_Queues_fk ;
	where TEQ.iActive_Flag = 1 ;
	and TEQ.iTemporary_Assignment_Flag = 1 and ;
	TEQ.tStart_Date <= m.ltTime and ;
	TEQ.tExpire_Date >= m.tdDate into cursor step1 
use in curFirst
** Possible problem - account assigned to the same investigator as commissioned and temp owner	
select count(trans.cTrans_pk) as iAccounts_Count, ;
	step1.cUsGrLink_pk, ;
	sum(trans.yCurrent_balance_amount) as yBalance ;
	from trans ;
	INNER join step1 ;	
	on trans.cTrans_pk = step1.cTrans_fk ;
	where trans.cResolution_Codes_fk is null ;
	group by 2 into cursor (m.tcAlias) readwrite
	
use in step1
select (m.tcAlias)
index on cUsGrLink_pk tag cUsgrlink

return
endproc
We need to find a way to run this SP on the server, then it would be faster. So, I guess, I may need to try it as a separate dll to retrieve the data. Any ideas here?

Thanks.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform