Planning ahead with "sql_calc_found_rows" being depreciated and using the new datatables 1.10.18 I have a question. For server-side processing you need to feed back the total and filtered total. So from what I gather I have to run 3 separate queries for every request, it seems excessive but I can't think of how to get the information without doing that.
// Grab the data with page offset
// for "data"
$query1 = 'SELECT .. FROM .. WHERE .. LIMIT ..'
// Grab filtered total which is the total using the "WHERE" without the "LIMIT"
// for "recordsFiltered"
$query2 = 'SELECT COUNT FROM .. WHERE .. '
// Grab the total records without the WHERE
// for "recordsTotal"
$query3 = 'SELECT COUNT FROM ..'
With complex queries and semi large datasets (100k-2mill) records and the fact this get's fired every time someone types a letter (every letter as they type in a word) in the search or hits the column sorting and changing pages the time and amount of queries/executions seems pretty crazy.
Am I missing anything or is this just whats required to use datatables having to fire off 3 database queries every request? Thanks.
from Datatables js and number of queries php mysql
No comments:
Post a Comment