-8

I am using Postgis as my backend for my project along with geoserver and openlayers. I have a table in my DB which gets filled up very frequently. Now when a user gets connected to a server , he can see the map with all the markers whose points are in the DB. Imagine the table keeps on filling up and there is no relation between user viewing the map and tables getting filled by values. Now suppose after some time when user clicks on certain button on the page, he has to see the map with markers of all the values present in the DB(along with new points inserted in the table since last time he clicked that button). This task can be made simple by making that button as submit button, but when the user clicks it, it reads the entire DB again(reloads the page) along with old points and projects on the map, instead of reading only the new points. This method is not at all good when I have 10000 points already in DB and only say 5 points getting added in the meantime. In this case it reads all the 10005 points instead of only 5 points.

So can anybody give me a solution on how to retrieve only the new points, still projecting all the points present in DB. To my knowledge Ajax can be used to do the same(which doesnt need reloading of the page) but I want a clear explanation of how to carry this work using postgis and geoserver.

Are there any special functions which can handle this?

If not, what is the better way to do this?

closed as primarily opinion-based by BERA, aldo_tapia, Dan C, whyzar, nmtoken Jan 31 '18 at 19:51

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

6

If you store the results in a dict in Javascript with the primary key from the DB as the key you could easily do this. When you request the features just check to see if the newly fetched primary key exists in the dictionary and if it does don't do anything with it and if it doesn't then add it. The problem with this approach is requesting all that data might be slow and redundant

My approach would be to

  1. put a timestamp in the db
  2. query with timestamp and sort on timestamp ascending
  3. your last item will have the most recent timestamp - store that value separately
  4. for new query just query for timestamp values greater than the most recent from the last query

Not the answer you're looking for? Browse other questions tagged or ask your own question.