LVL 17
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ok - there is something called as BLOCKFACTOR & MAXROWS in CFQuery / CFStoredProc !
I generally use this for my queries - run thru paging.

Few Optimization tips :

1. Use CFQueryParam to the Fullest [Bind Variables are a gr8 help - with text / numbers / dates / list etc ...]
2. Use BlockFactor in CFQuery / CFStoredProc. [the value of block factor shld be ur page size (maxrows in paging file)]
3. Use MAxrows in CFQuery / CFProcResult [the value as - StartRow + Maxrows]

Eg :
<CFQUERY NAME="Qry_" DATASOURCE="Atomic_Dsn" BLOCKFACTOR="#Maxrows#" MAXROWS="#StartRow+MaxRows#">
    Select .....


using this - u only fetch the required number of records from the DB [50 if maxrows=50] & not all 2000

PS : read thru for more information !


Tacobell777Author Commented:
Is this an Oracle thingy?
Nope works with SQL as well ... but teh article was talking abt Oracle in particular

Ive used the sample example [given above] with both Oracle & MS SQL ...
give it a try & see for urself !

The articles were just a means of giving u more information on my example !
10 Holiday Gifts Perfect for Your Favorite Geeks

Still have some holiday shopping to do for the geeks in your life? While toys, clothing, games, and gift cards are still viable options for your friends and family, there’s more reason than ever to consider gadgets and software.

Tacobell777Author Commented:
I tried it and it doesn't do anything for me. Then I did some research and foudn the following
maxrows specifies the maximum number of rows. blockfactor specifies the number of rows that CF will attempt to store in the database driver's storage buffer upon each row fetch. The two don't have anything to do with each other. The buffer is 32 Kb, so you can figure out how many rows (assuming the maximum possible row length) can fit into the buffer, then specify that number as the blockfactor attribute value. This is a performance enhancement; it makes getting the data faster. It doesn't affect how many rows will be returned by your query.

I don't think blockfactor does what you think it does..
Sorry.. Proof me wrong - please, coz it would be nice if it would work.
Tacobell777Author Commented:
Straight form the source "Corfield"

Adding blockFactor to a query can significantly improve performance. To add blockFactor, examine the data that is being returned. Determine the maximum size (in bytes) of each row. Take that size and determine how many times that number would divide into 32k. That number is your blockFactor, but be aware that the max blockFactor is 100. So, if for example you were getting 200 bytes per row, you could easily fit over 100 rows into the 32k buffer that CF 'grabs' at one time.

If you know at runtime that you will have less then 100 rows returned, for example you're writing a query that either returns 0 or 1 rows, do not bother adding the blockFactor attribute.
yes 2 are not related

blockfactor : will retrive the records faster from teh DB.
maxrows : Specifies the maximum number of rows you want returned in the record set.

by giving the parameter as [startrow+maxrows] - u'll be fetching only 1+50 = 51 records the first time & not all the 200 records
however on 2nd page - u will be fetching 51+50 = 101 records
& on 3rd page - u will be fetching 101+50 = 151 records

yes i agree - with this u cannot limit the fetch count to 50 all the time ... but i guess its better than retrieving all the 2000 everytime. & also how many users u think wld wanna go beyond the first 10 pages ... thats not more than 500 records for u ... still better than 2000 !

read thru this for getting the PRROF u asked for :)



PS : I hope u are not misinterpreting my suggestion - i didnt relate maxrows & blockfactor... cos when i use paging - i set the startrow & maxrow for each page & those are the variables used in the CFquery - so ur query wld actually look without those variables as

instead of
<CFQUERY NAME="Qry_" DATASOURCE="Atomic_Dsn" BLOCKFACTOR="#Maxrows#" MAXROWS="#StartRow+MaxRows#">

I hope that sorts out teh confusion in coldfusion :)
Tacobell777Author Commented:
I'll have a read through your answer in detail later, but I was aware of Maxrows, that still gets more records than I want.
If your on page 20 and displaying 10 records per page, that are 200 records you are retrieving....

yes thats the best - i can do for u at this point of time ...
Incase i get more info & a better solution - i wld let u know !

Closed, 250 points refunded.
Community Support Moderator
Experts Exchange

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.