A dirty hack for faster search
  • for simple search
    on library.js locate this
    oTable.fnSetFilteringDelay(350);
    and replace it with this
    oTable.fnFilterOnReturn();  
    you will have to add the datatable function : fnFilterOnReturn()
    located here
    http://datatables.net/plug-ins/api (expand the fnFilterOnReturn by clicking the details link and copy the function)
    paste it either at the end of dataTables.fnSetFilteringDelay.js or somewhere that it can be called (maybe library.js)
    this will enable you to search on the simple search by pressing the return key thus preventing multiple querys to be done on the database on every character typed. Alternatevely and more easily you can simply increase the timer to 5000 (5 seconds) on oTable.fnSetFilteringDelay(350); -> oTable.fnSetFilteringDelay(5000); without adding any function making the search with a 5 second delay.
    ---- Advanced search--
    On advanced search I couldn't do something similar.
    What I did though and it is a bit dirty is enabling the search when a '%' character inserted on the end of each string typed.
    this will fire the search once for every string when the '%' inserted in a field instead of firing a query on every character typed.
    in ibrary.js locate :
     else if (searchTermType === "n") {
                        regExpr = new RegExp(numericRegEx);
                        if (searchTerm[i].charAt(0) === "-") {
                            searchTerm[i] = searchTerm[i].substr(1);
                        }

    under it add
    else if (searchTermType == "s")
                    {
                    if (searchTerm[i].charAt(searchTerm[i].length - 1) !="%")
                      {allValid = false;}
                    } 

    '%' has to be added on the end of every string typed in order for the query to be fired
    If anyone has a better solution please share.
    This is a dirty hack not extensively tested. USE AT YOUR OWN RISK.

    Post edited by George Vasilopoulos at 2014-01-27 19:53:39
  • 3 Comments sorted by
  • Vote Up0Vote Down hoerichhoerich
    Posts: 627Member, Airtime Moderator
    nice one, thx 4 this
    Official Airtime Forum Manager
    --------------------------
    Most of the time an issue is located between keyboard and chair.
  • it's nice that someone finds this usefull. But the fact is that this is a dirty hack. I wish it was not. And I wish it  I had a more clean solution but I'm not a programmer I'm a sysadm. Unfortunately things like datatables or *faces considering java  do things that are very nice when you have 10000 records table on a rdbms but if you have a 20000000 records db these have major drawbacks.scanning the entire database on every character typed is simply not sensible.. I think that all these solutions have to be reviewed. Adding an enter to fire a search is not that bad at all.. this is not an airtime problem .. this is a datatables point of view problem which have to give extra options on fnfilter functions.. 
  • Hey @George Vasilopoulos this is definitely a useful solution for the search. Removing the search on keypress I think is a good decision at this point in Airtime. Going to look into adding this to the codebase
    Post edited by Naomi at 2014-02-10 12:17:06