Solved

JQuery and cfquery

Posted on 2013-12-02
5
414 Views
Last Modified: 2013-12-10
I current have a page where I load an query when page load, and it generate a table of content. Current I have a pagination system that will make an AJAX call to the DB and return a query with the start row and end row.

Now my question is, is it better to load all the data from the query in an array, json or any other format and use AJAX to query that result set and not make the call to the DB anymore?
0
Comment
Question by:Medrise
  • 2
  • 2
5 Comments
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 334 total points
ID: 39691468
All depends on how much data you're loading. Pulling everything at once saves trips to the db, but the browser still has to parse it all and trying to parse a LOT of data can cause a browser freeze or get bogged down. If it's a small amount of data,it doesn't make much difference. Either way is fine.  However, once you move beyond that it's typically better to pull a page of data (10,20,50 records..) at a time to get the best balance of browser and server performance.
0
 

Assisted Solution

by:Medrise
Medrise earned 0 total points
ID: 39691528
_agx_ Thanks for the reply... It will depend on the user, some user will have a few records (10 to 50) and some may have 100 to 1000 records...

I guess I will keep like I have right now.  I have a stored procedure that takes a start row and end row... I guess it would be better to keep like that.
0
 
LVL 15

Assisted Solution

by:Gurpreet Singh Randhawa
Gurpreet Singh Randhawa earned 166 total points
ID: 39691793
Well for that such of work, I would prefer DataTables Jquery Plugin, server side code very easy and configurable to use

2. You can either use cfgrid to have such functionality where data comes in chunks and it does not freeze the browser anywhere

DataTables is more better as data comes in JSON format from backend and easy to display on screen

as AX Pointed out, loading much data will freeze the browsers and may not be a viable solution to work

if you have very little data i just suggestgo by the cfdiv way, the below post will help

http://www.raymondcamden.com/index.cfm/2008/12/14/Ask-a-Jedi-Simple-ColdFusion-8-Ajax-Pagination
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 334 total points
ID: 39692782
(Edit)

@Medrise - Yeah, if the number of records is potentially unlimited, then sticking with db side pagination is better. If you pull all the data across into the browser, it might work swimmingly for some users (10-50 records) but terrible (or not all) for others with more records.  (Side note, the ExtJS site is a good example of too much javascript activity IMO. It works on one of my computers ok, but frequently freezes the browser on another due to too much javascript activity). Sticking w/db pagination will provide good balance of consistency and performance on both the db and browser side for all users.
0
 

Author Closing Comment

by:Medrise
ID: 39708053
Thanks for all the info...
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now