Goat Posted July 23, 2010 Share Posted July 23, 2010 Greetings, people I know it is possible to place small amount of data on server without using database. All session data is placed on server, not client, so anytime you put something in $_SESSION array, you are placing temporal data on server. I am pretty sure that's hella lot faster than putting it in database. My question is simply this: Is it possible to place data in an array or something that would be available to all who come, not just current user (like SESSION), without using database? This is mostly needed in developing chat script, where optimization is a key and databases are slow Link to comment https://forums.phpfreaks.com/topic/208700-php-temporary-storage-of-data-other-than-database/ Share on other sites More sharing options...
Mchl Posted July 23, 2010 Share Posted July 23, 2010 I am pretty sure that's hella lot faster than putting it in database. Don't. You might be surprised. Database can be configured to store data in memory, which is 'hella lot' faster than storing anything in the file (as sessions by default do). Sessions can actually be configured to use database on the other hand. My question is simply this: Is it possible to place data in an array or something that would be available to all who come, not just current user (like SESSION), without using database? This is mostly needed in developing chat script, where optimization is a key and databases are slow Don't know why you think databases are slow. Other ways of persisting data is to store them in flat files (see fopen) but this induces several problems when too many people try to read/write same file at once. Link to comment https://forums.phpfreaks.com/topic/208700-php-temporary-storage-of-data-other-than-database/#findComment-1090312 Share on other sites More sharing options...
Goat Posted July 23, 2010 Author Share Posted July 23, 2010 Maybe it's just perception, I don't know. I have assumed (mother of all fuckups I know) that databases most often hold data on hard drive (I know they don't have to but oh well...) while $_SESSION is held in RAM (and is therefore faster). I know lot of folks are saying database access is the biggest bottleneck Is there some query or something that will force MySQL database to hold certain table in RAM whenever possible? I have full access to server, by the way, so I can configure or install anything I want. Also how to cache certain queries in MySQL? Link to comment https://forums.phpfreaks.com/topic/208700-php-temporary-storage-of-data-other-than-database/#findComment-1090325 Share on other sites More sharing options...
Mchl Posted July 23, 2010 Share Posted July 23, 2010 MySQL tries to load table into RAM when data from table is accessed for the first time and keeps it there as long as it's accessed often enough that other tables don't need it's place. You need to give MySQL enough RAM to be able to store your most commonly used tables in memory. People often run their servers on default settings, which used to be really modest for a long time (and that's one of the reasons you hear of 'database bottleneck'). You will see a bit better performace in writing when using InnoDB database engine, because of the way it handles writes (I won't even try to explain it in detail because I hardly understand it myself ) There's also a separate storage engine called MEMORY that will always store your data in memory. Be careful... on server restart, all data in such tables are lost. Because of this it might seem useless at first, but it has it uses (like caching aggregated data). For query caching (useful thing indeed when used properly) see http://dev.mysql.com/doc/refman/5.1/en/query-cache.html Link to comment https://forums.phpfreaks.com/topic/208700-php-temporary-storage-of-data-other-than-database/#findComment-1090362 Share on other sites More sharing options...
Goat Posted July 23, 2010 Author Share Posted July 23, 2010 Thanks Mchl, I'll look into it. Link to comment https://forums.phpfreaks.com/topic/208700-php-temporary-storage-of-data-other-than-database/#findComment-1090401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.