Welcome Guest, Not a member yet? Register   Sign In
Is this bad sql to count total for pagination? (CI3-dev)
#5

[eluser]a_h_abid[/eluser]
[quote author="joergy" date="1403472148"]ever thought about
select count(id) from...
or similar, if You expect many records?

IMHO this
$this->db->query(preg_replace('/LIMIT.+$/i','', $sql))->num_rows();
isn't easy to read. Why not splitting...[/quote]

Right now wrote like this so you guys can understand my current process of getting total rows record.

I do use count('id') for simple queries, but sometimes i have complicated queries that may have subqueries, union etc. within it. In those case using it doesn't produces the required result.

[quote author="www.sblog.in" date="1403516578"]If you have millions of records then check for paging optimization like http://www.databaseskill.com/1159218/[/quote]

Thanks for link. But I can't seems to understand the english he written there. Is he talking about setting index keys?


Messages In This Thread
Is this bad sql to count total for pagination? (CI3-dev) - by El Forum - 06-23-2014, 10:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB