Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Mike Yearwood
  Where is Mike Yearwood?
 Toronto
 Canada
 Mike Yearwood
 To: Binod Binani
  Where is Binod Binani?
 Kolkata
 India
 Binod Binani
 Tags
Subject: RE: how to optimize/fast this
Thread ID: 268658 Message ID: 268970 # Views: 35 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Thursday, July 15, 2010 6:30:23 PM         
   


> >
> > Filter has always been good - just as good as SELECT - SQL and just as good as LOCATE FOR. They all do the same inside.
> >
> > Mike Yearwood
> > Microsoft MVP Visual FoxPro 2008, 2009
> > We have enough youth. We need a fountain of smart!
> > There may be many ways to skin a cat, but there are very few right ways to do it.
>
> Respected Sir,
> Thanx a lot for ur reply.
>
> I m doubt. ie: my_table having about 75000 records and index on pty_code,dates
>
**1
> Select Dates,pty_codes,Sum(Amt) group by dates,pty_code from my_table where pty_code=m.my_pty_code and betw(dates,m.start_dates,m.end_dates) into cursor tmp_cursor

> ****
Above two process r fetching the same tables and giving same reslult in mu. But time consumption are different. it is my experinece only. I m not as experts as others.

The timing differs because you are executing more lines of code, and because your filter is not the same. You are also comparing SQL against dbase style code. Your dbase style code is processing after setting the filter, which SQL does in one shot.

*This part takes about as much time as SQL does.
Sele my_table
set filt to betw(dates,m.start_date,m.end_date) and pty_code=m.mty_code
locate

*This part is now summing and producing the output which SQL does internally and much faster.
set order to tag ixdates
scan
    store dates to xdates
    sum while dates=m.Xdates to lnSum
    insert into tmp_cursor (dates, pty_code, sum) values (m.xdates, m.pty_code, m.lnSum)
endscan
RETU


Mike Yearwood
Microsoft MVP Visual FoxPro 2008, 2009
We have enough youth. We need a fountain of smart!
There may be many ways to skin a cat, but there are very few right ways to do it.

ENTIRE THREAD

how to optimize/fast this Posted by mk sharma @ 7/13/2010 8:33:26 PM
RE: how to optimize/fast this Posted by Anil Sharma @ 7/13/2010 8:44:44 PM
RE: how to optimize/fast this Posted by mk sharma @ 7/13/2010 8:59:49 PM
RE: how to optimize/fast this Posted by Jun Tangunan @ 7/14/2010 3:17:33 AM
RE: how to optimize/fast this Posted by mk sharma @ 7/14/2010 8:18:12 AM
RE: how to optimize/fast this Posted by Jun Tangunan @ 7/14/2010 10:21:01 AM
RE: how to optimize/fast this Posted by Jun Tangunan @ 7/14/2010 10:59:55 AM
RE: how to optimize/fast this Posted by mk sharma @ 7/14/2010 11:58:18 AM
RE: how to optimize/fast this Posted by Jun Tangunan @ 7/14/2010 12:19:49 PM
RE: how to optimize/fast this Posted by Jun Tangunan @ 7/14/2010 12:23:28 PM
RE: how to optimize/fast this Posted by Binod Binani @ 7/14/2010 8:00:52 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/14/2010 10:40:06 PM
RE: how to optimize/fast this Posted by mk sharma @ 7/15/2010 8:36:51 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/15/2010 6:31:43 PM
RE: how to optimize/fast this Posted by mk sharma @ 7/16/2010 6:31:23 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/16/2010 6:59:23 AM
RE: how to optimize/fast this Posted by Samir H. @ 7/16/2010 7:43:23 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/16/2010 7:25:46 PM
RE: how to optimize/fast this Posted by mk sharma @ 7/16/2010 7:48:03 AM
RE: how to optimize/fast this Posted by tushar @ 7/16/2010 8:05:16 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/16/2010 7:30:36 PM
RE: how to optimize/fast this Posted by Binod Binani @ 7/15/2010 2:27:34 PM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/15/2010 6:30:23 PM
RE: how to optimize/fast this Posted by Binod Binani @ 7/17/2010 8:01:16 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/18/2010 7:30:27 PM
RE: how to optimize/fast this Posted by Binod Binani @ 7/19/2010 9:49:06 AM
RE: how to optimize/fast this Posted by Mike Yearwood @ 7/19/2010 3:03:16 PM
RE: how to optimize/fast this Posted by Samir H. @ 7/14/2010 3:51:21 AM