This is an issue which interests me too. The answer Scott gives makes absolute sense to me, but all the PHP/MySQL books I've seen (and MySQL can't be that different from Sqlite3 in this respect) seem to go the way of a new query to the database every time a different set of data is needed, rather than keeping all the data in an array, even with small inconsequential tables. I suppose if there is a possibility that the db tables may be updated while the user is online this approach is valid. Or maybe there is a downside to PHP arrays, I can see that a huge array might have memory implications, especially on a busy shared server.
Michael Hooker ----- Original Message ----- From: "Scott Baker" <[EMAIL PROTECTED]> To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> Sent: Monday, February 18, 2008 4:33 PM Subject: Re: [sqlite] which is faster, PHP or SQLite? > Sam Carleton wrote: >> I am new to SQLite and databases, so I am stil learning how to >> optimize their use... >> >> I am working on a "shopping cart" type of feature, it is actually a >> favorites feature for a system that displays images in multiple >> galleries. There is a SQLite table that contains the user_id, >> gallery_id, and image_id. When a index page is displayed, only a sub >> set of the images in the gallery are displayed. So the question is >> what will be faster: >> >> 1: Doing a SELECT for each image on the favorites table to see if it is >> selected >> 2: Doing one SELECT to get all the images for the current gallery and >> store that into a PHP array and then simply look in the PHP for each >> image? >> >> My thought is option 2. Is that correct? > > The less database hits you have to do, the faster your code will be. > Getting all the data into a PHP data structure should be the way to go. > > > -- > Scott Baker - Canby Telcom > RHCE - System Administrator - 503.266.8253 > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users