CodeIgniter Forums
[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: [UPDATED 2009-03-09] Improved "queries efficient" CI Session library (/showthread.php?tid=16992)



[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-22-2009

[eluser]Matthieu Fauveau[/eluser]
Hi guys,

I don't know if you noticed it yourself but using Flashdatas and CI native Session library can make several unefficient queries and therefor slow down the loading of your website.

Following is a modified library that will make one SELECT and one UPDATE - if needed - instead of several UPDATE queries.

I'm currently testing it and it seems to work great. Your inputs are obviously welcome.

Matt.

*** UPDATED 2009-03-09 ***

Just noticed that CI stores IP addresses as strings, it's however an unefficient way of storing IP addresses which are basically unsigned 32-bit integer. MySQL will also perform better when doing an integer comparison instead of a string comparison.

The attached file has been updated to take this changes into account. You will need to ALTER your session table using the following command for it to work :
Code:
ALTER TABLE `ci_sessions` CHANGE `ip_address` `ip_address` INT UNSIGNED NOT NULL DEFAULT '0'



[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-23-2009

[eluser]Wuushu[/eluser]
Bump Smile


[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-23-2009

[eluser]Matthieu Fauveau[/eluser]
Thanks for bumping Wuushu Wink
I'm hoping CI guys see that post.


[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-23-2009

[eluser]johnwbaxter[/eluser]
If you want it noticed you should post it in the feature requests forum or maybe even the bug reports forum if you think the under efficiency is worthy of it being a bug Wink


[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-23-2009

[eluser]Matthieu Fauveau[/eluser]
I see your point. I don't think it should be considered as a bug tho. And it's not a feature request either... Anyways I'm sure one of the Dereks will notice that post Wink


[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-29-2009

[eluser]Matthieu Fauveau[/eluser]
Just updated the post to add a little MySQL trick that also improve efficiency (only under high load but still).


[UPDATED 2009-03-09] Improved "queries efficient" CI Session library - El Forum - 03-29-2009

[eluser]Xeoncross[/eluser]
Thanks, this is one thing that really bothers me as well. I don't like seeing lots of queries for session data in my logs...