hermawanramadhan / CodeIgniter4-DataTables

MIT License
92 stars 38 forks source link

search delay with multi-column-search? #25

Closed gixxy22 closed 1 year ago

gixxy22 commented 1 year ago

hi,

is there a way to use [throttle](https://datatables.net/reference/api/%24.fn.dataTable.util.throttle()) to add a 200ms or so delay on key-presses for multi-column-searches?

I can add searchDelay to the main global search, but not sure how I can implement throttle on multi-column-searches, each key-press will instantly fire a MySQL query, and if on a table of 1million rows when searching for 'computer', its going to fire 8 expensive queries when it only needs to fire 1. and as each query will be less expensive with every key-press it seems to be a huge performance boost to add a slight delay.

for example searching for 'c' will probably return 900k rows, 'co' 600k rows, 'com' 300k rows, but 'computer' maybe only 700 rows.

gixxy22 commented 1 year ago

and/or a minimum character requirement before sending a search request? for example minimum 3 characters

hermawanramadhan commented 1 year ago

this is client side issue not this serverside library. so many solution when you search on google and stackoverflow. you can manipulate all your problem event on keyup.