How Would You Tackle This Scenario?

Subtitle: I'm a noob and I'm pretending like this is a theoretical example.

I'm going to borrow a page from the Jedimaster's playbook and present this scenario as a "puzzler" to the CF community. I know it will seem a little naive and noobish, but hell - a lot of my posts show that I'm noobish and well, I really don't care. I always say if you're not going up you're going down - so I always try to gain more knowledge and if it helps someone else out there along the way then cool.

So here's the scenario: In my last post I shared a UDF that I had written earlier today that I plan to use to help me efficiently page through query results using a Flex datagrid. Bruce Phillips commented that he thought it would be interesting to try and recreate this functionality within the Flex front end with Actionscript. I started to reply in the comments, but decided to turn the issue into a whole new post. While his logic is valid in that it avoids recurring calls to the component, that idea wouldn't quite work in my scenario. Why wouldn't it work you may ask, well that's the noobish part. Let me give a little background to my application (without spoiling too much since it's still 'top secret').

Essentially the Flex application will deal with a potentially large dataset (for those in the OO crowd you could call this the 'gateway'). Since the dataset can grow quite large I planned to cache the data to improve performance. To do so, I created a query in my components instance and planned to cache the query in the instance data when the component is init()'d (onApplicationStart). My Flex app will interact with the component via a proxy component which will return the base component from the application scope. So far, so good. Now I have a query that can be returned to the Flex front end (and paged via the UDF I created). Finally, here's the part I still don't feel comfortable with. My component will have the standard CRUD methods for interacting with the dataset - not DAO's per se (because I just ain't that cool yet), but rather simple methods to add/update/delete items. My thought is that when the standard add/update/delete happens I could simply use some utility functions to add/update/delete the query in the instance data (yeah, that's the part you can laugh at). Doing so will keep the instance data 'live' and keeping it in the instance will ensure that the data is available to all active sessions upon there next call to the component.

If you're still with me - thank you ;). So what are my alternatives? Obviously I could create a refresh method and call it on A/U/D - but it seems like that would defeat the benefits of caching (if the cache has to constantly be updated).

Comments
As usual, the answer is... it depends!

For one thing, it depends on what you mean by "a potentially large dataset". Is a large dataset 100 records, 1,000 records or 10,000,000 records? How much data is there in each record?

I would not store what I consider to be a large dataset in memory as most of that dataset will likely never be called. I like to deal with paging at the database level so I only return what is needed to the client ( in this case ColdFusion ).

Gus
# Posted By Gus | 11/28/06 8:05 PM
How large? Hard to say - no more than a few thousand probably (1000-2000).

Paging at the db level - good idea. Only pain would be coding (dev environment is access - prod will probably be MSSQL).

I guess paging at the db level would eliminate the need to cache the query - just A/U/D straight into the db and refresh by returning a new paged recordset.

Know of any good examples of db level paging? A coworker mentioned a MSSQL proc that he had today - maybe I should look into that.
# Posted By todd sharp | 11/28/06 8:10 PM
1 to 2 thousand records isn't that much... I think your caching scheme sounds like a big solution to a small problem. As for paging in the database, it's easy in MySQL, but a pain in MSSQL because it doesn't support offset (though I hope they changed this in 2005, but I don't have any experience in that yet, so if you are talking 2005, you should look into offset support). You can do it in MSSQL 2000, but it requires a subquery which isn't ideal. Anyway, I would actually just say, refresh the query when it is updated...and save yourself the complication.
# Posted By Brian Rinaldi | 11/28/06 8:39 PM
I like that answer Brian :)

So you don't think 1-2k isn't going to kill the memory? What if I were talking 10-20k? What is the "limit" for memory based caching? As Gus says - it probably "depends" --- isn't this a fun world we live in as programmers?
# Posted By todd sharp | 11/28/06 9:25 PM
I guess if that was the case my question would be, what would you be doing creating an application that pages through 10,000 records? I mean how usable is that? How many records would any one user ever really page through? Perhaps there is a more usable way to retrieve these records that would better address this issue from the standpoint of how the user might actually access the data.
# Posted By Brian Rinaldi | 11/28/06 10:08 PM
That was really more of a hypothetical - in all reality I'd be lucky if the amount ever reaches a few hundred. I'm just curious as to how massive resultsets are handled by larger applications. For example - Google - how do they page through a million search results -- and like you said, why bother? I mean how many of us have really ever made it past page 5 or 6 in Google?
# Posted By todd sharp | 11/29/06 7:51 AM
can u give me a source code of paging which is implemented in flex data grid
.plz
# Posted By Rahul Dhaware | 1/8/07 11:20 PM
You can use this example:
SELECT * FROM (
SELECT TOP 5 * FROM (
SELECT TOP 5 * FROM (
SELECT Top #tel * From Objecten Order by Objectnummer ASC
) AS a ORDER BY Objectnummer DESC
) AS b
) AS c ORDER BY Objectnummer ASC

From code:
For i As Integer = total mod step To total Step 5
thread = New System.Threading.Thread(AddressOf loadObjects)
thread.Start(#tel)
Next

Just an example, not useable like this
# Posted By Martijn Wessels | 1/31/07 8:31 AM

Calendar

Sun Mon Tue Wed Thu Fri Sat
     12
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       

Subscribe

Enter your email address to subscribe to this blog.

Tags

actionscript ajax blogging cfsnippets coldfusion flash forms flex funny stuff misc model-glue off topic personal project learn slidesix sql

Recent Comments

ColdFusion/Sharepoint Integration - Part 1 - Authenticating
todd sharp said: Jenn: Check your email. Todd [More]

ColdFusion/Sharepoint Integration - Part 1 - Authenticating
Jenn said: When does the next issue of FAQU come out? For that matter is it at all possible to get a preview o... [More]

A Major Milestone In My Marriage
Brian Meloche said: I converted my wife last year. That said, I find Firefox 3 a bit crashy. [More]

SlideSix Gets PDF Support
todd sharp said: Do you mean add numbering to the PDF output? If so, yeah, that would be easy. Just to be clear tho... [More]

SlideSix Gets PDF Support
salvatore fusto said: nice work Todd, but can you add slide numbering: 1/N, 2 of N and so long? it would be useful. regard... [More]

RSS


coldfusionbloggers

FullAsAGoog MXNA

Consumed By Feed-Squirrel.com