Welcome Guest, Not a member yet? Register   Sign In
CI-based Web Sites Performance
#19

[eluser]tonanbarbarian[/eluser]
ok i sort of agree with lewis

i am thinking the reason that the db->result type functions were created were for convenience. it makes it easier to use methods to move back and forward amongst the records

while it does mean you have to parse through a loop twice there are things you can do to improve performance

for example
Code:
foreach ($query->result() as $row) ...
is fairly slow because it has to run the function on each iteration of the loop
use
Code:
$rows = $query->result();
foreach ($rows as $row) ...
instead

how much slower is it to have to process the loop twice though?
well that does depend on how many records you are processing.
if you are using a paginated list you wall always be limiting the number of records you retrieve.
So if it is 5, 10, 20, 50 or even 100 records in the result set then it is going to be very fast because the loop size is small and I would not worry about this as an issue.

If you are not using limits and you are having to pass 1000's of records then the extra processing may be noticable, but this is not something that happens often, and you could consider breaking your process into batches anyway and refreshing the pages in between.

having said all of this I have expressed a desire before to have something like
Code:
$this->query->fetch_object();
$this->query->fetch_array();
each of which just gets the next record but does not do any of the other processing that CI normally uses to "cache" the result data


Messages In This Thread
CI-based Web Sites Performance - by El Forum - 02-03-2008, 07:15 AM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 11:22 AM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 02:01 PM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 03:09 PM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 04:54 PM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 06:23 PM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 08:33 PM
CI-based Web Sites Performance - by El Forum - 02-03-2008, 10:27 PM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 02:44 AM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 03:42 AM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 08:43 AM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 04:19 PM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 04:54 PM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 06:42 PM
CI-based Web Sites Performance - by El Forum - 02-04-2008, 09:38 PM
CI-based Web Sites Performance - by El Forum - 02-09-2008, 06:10 AM
CI-based Web Sites Performance - by El Forum - 02-09-2008, 01:51 PM
CI-based Web Sites Performance - by El Forum - 02-09-2008, 02:11 PM
CI-based Web Sites Performance - by El Forum - 02-09-2008, 03:55 PM
CI-based Web Sites Performance - by El Forum - 02-09-2008, 04:28 PM
CI-based Web Sites Performance - by El Forum - 02-09-2008, 08:21 PM
CI-based Web Sites Performance - by El Forum - 02-10-2008, 06:41 AM
CI-based Web Sites Performance - by El Forum - 02-10-2008, 04:44 PM
CI-based Web Sites Performance - by El Forum - 02-10-2008, 10:10 PM
CI-based Web Sites Performance - by El Forum - 02-11-2008, 03:37 PM
CI-based Web Sites Performance - by El Forum - 02-12-2008, 09:16 AM
CI-based Web Sites Performance - by El Forum - 02-12-2008, 09:26 AM
CI-based Web Sites Performance - by El Forum - 02-12-2008, 10:02 AM
CI-based Web Sites Performance - by El Forum - 02-12-2008, 01:51 PM
CI-based Web Sites Performance - by El Forum - 02-12-2008, 02:01 PM
CI-based Web Sites Performance - by El Forum - 02-12-2008, 02:34 PM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 03:35 AM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 05:14 AM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 07:44 AM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 08:53 AM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 09:49 AM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 12:38 PM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 01:21 PM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 01:24 PM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 01:32 PM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 02:57 PM
CI-based Web Sites Performance - by El Forum - 02-13-2008, 08:03 PM
CI-based Web Sites Performance - by El Forum - 03-16-2008, 05:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB