Constantly updated list
am 16.09.2007 16:37:47 von Frobinrobin
Hi I need to create a list that is updated whenever a change occurs in
the database.
I first used Ajax to poll a part of the page and query the database
every 5-10 seconds, downloading the data every time... however as
someone pointed out.. polling is bad practice and uses a lot of
bandwidth.
I've given it some thought and I'm wondering whether I can use polling
more efficiently?
For example:
I have a function that querys the database and returns my results in a
structured array - I assign this as $current_list.
Then I poll a page that querys the database every 5-10 seconds and
compares $current_list against $new_list ... if there is a difference,
then it refreshes the $current_list array :)
As I'm refreshing the array on the server side and only downloading
when there is a change this should be much more bandwidth friendly
right?
Is there any point in only updating the part of the array which has
changed it's fairly small data (The array will have a max of ten
records (sub arrays) with 6 fields in each)
Many Thanks
Re: Constantly updated list
am 16.09.2007 19:48:35 von Jerry Stuckle
FrobinRobin wrote:
> Hi I need to create a list that is updated whenever a change occurs in
> the database.
> I first used Ajax to poll a part of the page and query the database
> every 5-10 seconds, downloading the data every time... however as
> someone pointed out.. polling is bad practice and uses a lot of
> bandwidth.
>
> I've given it some thought and I'm wondering whether I can use polling
> more efficiently?
>
> For example:
> I have a function that querys the database and returns my results in a
> structured array - I assign this as $current_list.
> Then I poll a page that querys the database every 5-10 seconds and
> compares $current_list against $new_list ... if there is a difference,
> then it refreshes the $current_list array :)
>
> As I'm refreshing the array on the server side and only downloading
> when there is a change this should be much more bandwidth friendly
> right?
>
> Is there any point in only updating the part of the array which has
> changed it's fairly small data (The array will have a max of ten
> records (sub arrays) with 6 fields in each)
>
> Many Thanks
>
Downloading one row vs. 10 rows is probably an insignificant amount of
overhead compared to the polling involved (unless your database is
updated a lot).
Personally, I'd be looking at a different way of doing it - for
instance, a java applet. HTTP just isn't a good match for this type of
operation.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Constantly updated list
am 17.09.2007 15:31:48 von colin.mckinnon
On 16 Sep, 18:48, Jerry Stuckle wrote:
> FrobinRobin wrote:
> > Hi I need to create a list that is updated whenever a change occurs in
> > the database.
> > I first used Ajax to poll a part of the page and query the database
> > every 5-10 seconds, downloading the data every time... however as
> > someone pointed out.. polling is bad practice and uses a lot of
> > bandwidth.
>
> > I've given it some thought and I'm wondering whether I can use polling
> > more efficiently?
>
> > For example:
> > I have a function that querys the database and returns my results in a
> > structured array - I assign this as $current_list.
> > Then I poll a page that querys the database every 5-10 seconds and
> > compares $current_list against $new_list ... if there is a difference,
> > then it refreshes the $current_list array :)
>
> > As I'm refreshing the array on the server side and only downloading
> > when there is a change this should be much more bandwidth friendly
> > right?
>
> > Is there any point in only updating the part of the array which has
> > changed it's fairly small data (The array will have a max of ten
> > records (sub arrays) with 6 fields in each)
>
> > Many Thanks
>
> Downloading one row vs. 10 rows is probably an insignificant amount of
> overhead compared to the polling involved (unless your database is
> updated a lot).
>
> Personally, I'd be looking at a different way of doing it - for
> instance, a java applet. HTTP just isn't a good match for this type of
> operation.
Pushing from server to client will break in a lot of scenarios. If you
control the infrastructure in between then you'll know if it will
work.
It may be cheaper to measure the change from a different direction
(e.g. mod time on the database file, triggers on the tables...)
C.