reset password
Author Message
plakhan
Posts: 37
Posted 16:12 Feb 23, 2015 |

Hello Professor,

For the extra credit part of the assignment, can we use jquery data tables instead of jquery autocomplete.? I think jquery data table will give a good UI along with the search functionality.

cysun
Posts: 2935
Posted 17:13 Feb 23, 2015 |

It depends on how you use it. It's important that you do NOT retrieve all the users as the number of users can be large. If you do Ajax paging/search with DataTables then it's OK.

plakhan
Posts: 37
Posted 09:51 Feb 24, 2015 |

Ok, i understand that the number of users might be large in the system. But for using auto complete we create a method in the controller and then get the data from the database using its dao. So  for e.g. i type a text "a" in the search box , and then i type "aa" in the search box. There would be 2 calls to the controller method which indeed calls the database twice. I understand that for the auto complete we can use like queries. So my question is, if we have large number of users, will the auto complete be a good solution to this, since the number of database call is equal to the number of character that we type in the search box.

I hope i am clear with my question.

cysun
Posts: 2935
Posted 11:19 Feb 24, 2015 |

The short answer is yes.

The long answer is that for large amount of data, query-every-time is the only feasible approach. Imagine you want to implement autocomplete for Facebook user search or Google query suggestion - the number of records is in the hundreds of millions, so you simply cannot afford to retrieve all data into server memory, send it back to client, then search it in client memory using JavaScript. Given that we have to do query-every-time, the key is then to execute the query very efficiently. Fortunately databases can usually do these types of search queries very fast, as long as you do not use LIKE '%term%' (we'll discuss this when we talk about full text search).

plakhan
Posts: 37
Posted 11:24 Feb 24, 2015 |

Much clear now. Thank you