CodeIgniter Forums
->row() without limit() causes high load - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: ->row() without limit() causes high load (/thread-70690.html)



->row() without limit() causes high load - khashabawy - 05-16-2018

i noticed that selecting row() without putting limit() in the active record is causing high load !!

anyone noticed that ?


RE: ->row() without limit() causes high load - InsiteFX - 05-16-2018

Of course it will it's pulling in all the records matching your search.


RE: ->row() without limit() causes high load - khashabawy - 05-17-2018

(05-16-2018, 03:19 AM)InsiteFX Wrote: Of course it will it's pulling in all the records matching your search.

It is supposed that results() does that but row() by default limits to 1 !!


RE: ->row() without limit() causes high load - mihiran - 05-17-2018

Use Prepared Statements with PDO


RE: ->row() without limit() causes high load - Paradinight - 05-17-2018

(05-17-2018, 12:32 PM)khashabawy Wrote:
(05-16-2018, 03:19 AM)InsiteFX Wrote: Of course it will it's pulling in all the records matching your search.

It is supposed that results() does that but row() by default limits to 1 !!

1. row return 1, but it does not limit the results from the database.
2. Add an index to the field. An index speed up the search.


RE: ->row() without limit() causes high load - khashabawy - 05-18-2018

(05-17-2018, 08:55 PM)Paradinight Wrote:
(05-17-2018, 12:32 PM)khashabawy Wrote:
(05-16-2018, 03:19 AM)InsiteFX Wrote: Of course it will it's pulling in all the records matching your search.

It is supposed that results() does that but row() by default limits to 1 !!

1. row return 1, but it does not limit the results from the database.
2. Add an index to the field. An index speed up the search.

Does not this considered a bug ? why does not row() limit to 1 row() ?


RE: ->row() without limit() causes high load - zjonsnowz - 05-18-2018

There is a reason for that.
Read the docs https://www.codeigniter.com/user_guide/database/results.html (Result Rows)


RE: ->row() without limit() causes high load - dave friend - 05-21-2018

(05-18-2018, 03:40 AM)khashabawy Wrote: Does not this considered a bug ? why does not row() limit to 1 row() ?

There is a difference between making a query and obtaining a results set from a query.