Page 1 of 1

Session variables grow huge for no reason

Posted: Fri Mar 14, 2003 2:41 am
by Tubbietoeter
Hi there,


I hope you guys can help me.
I got a very slow database here so I decided to save the results of the select statements into a session variable for futher use. Right now the select returns 31000 rows, this is 5 MB in a flat file. I wanted to save the result array into a session variable.

Now, thats my problem; at the end of the script when PHP writes the session, it fails. I get a message that my allowed memory size is exhaustet.
The memory limit is 50 MB so I really don't know what PHP is saving there if I want to save 5 MB in an array.

The array has 2 dimensions, 10x31000 ($array['COLUMN'][index]).


Please help me ... this is driving me nuts!! :roll:


Thanks,


Stefanie

Posted: Fri Mar 14, 2003 5:07 am
by volka
take a look at http://www.php.net/manual/en/configurat ... rce-limits
Are you sure your database is that slow to justify writing so many records to a flat file?

Posted: Fri Mar 14, 2003 5:20 am
by Tubbietoeter
Well the database needs more than a minute to return the results of that select. A colleague is working on that, he tries to speed up the database. Unfortunately the workstation with the database is ancient so I don't count on him doing any miracles.


Er, I suppose I have to be root in order to set the memory limit higher? I'd need to tell my admin to do this for me then.



Anyways, I don't want to save the results in a flat file but in a session variable. I just don't know why that damn variable gets so huge ... :roll:

Posted: Fri Mar 14, 2003 5:30 am
by volka
sessions are stored in flat files by default and the file is read at session_start() (for each invokation of the script for the client with this sessionId) and written when your script ends...

and just a small calculation: By default you have 8mb, that is 8*1024*1024=8388608 bytes
8388608 / (31000*10) = 27,..
Even if(!) php wouldn't need any other memory... ;)

Posted: Fri Mar 14, 2003 6:11 am
by Tubbietoeter
So where does that error message come from?
I don't get it ...

Posted: Fri Mar 14, 2003 6:46 am
by volka
Even if(!) php wouldn't need any other memory...
That is not the case and even 27 bytes per entry is ...hmmm... tight?

There's no chance to prevent 31k recordsets (to be stored)?

Posted: Mon Mar 17, 2003 2:39 am
by Tubbietoeter
No not really. The results are shown in a table with x pages, the user can flip through the pages. if I would select only the results i needed for the current page the user would again have to wait a minute when he goes to the next screen. Also the entries must be sorted on users click.
if I do that live on the DB (as I originally intendes) things just get too slow.

I'll try materialyzed views today maybe this helps.


Thanks for your help!


Steff