Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199908

Re: [PHP3] Spliting reports from oracle queries From: Aaron Leon Kaplan (jjl <email protected>)
Date: 08/05/99

On Thu, 5 Aug 1999, Nold wrote:

> I dont think you need dual at all.
>
> rownum should work fine anywhere.
>
> ... but just thinking about it what if your tables are huge (like most
>search engines are) or you get a lot of hits (like most search engines
>do) do you really want to run the same query 15 times for a 15 page
>report?
>
> You may want to run the whole query and store a result array temporarily
>somewhere. Maybe a global variable with a timestamp/unique id? and
>generate all your next pages from this. This would also allow you to have
>calculate stats on the first page such as number of rows etc without
>another query.
>
>

Ok, if you cache the results in php, the next questions will be:
1) what happens if the data has changed in the meantime in the DB itself?
   -> you have cached outdated rows
2) when will the cached rows be removed from php's memory?
   As far as I have been following the php4 discussion about reference
   counting on variables.. the array with the rows will be deleted as soon
   no user requests a page which has a reference to that array.

IMHO the way to do it should be:
  a) let the DB query optimizer decide if the query should be cached.
     AFAIK Sybase, etc. have very intelligent optimizers. They work with
     statistics on queries. This solves (1)
  b) make the latency time which occurs when you connect to your DB
     as small as possible. (persistent connections)

Any experiences on how to tell the query optimizer that it should cache
this particular query (in Oracle)?

I would highly appreciate it if someone from the php devel. team could
comment on the above.... this issue gets really important when you have
heavy traffic on your site.

Aaron.

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>