<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Rewrite of GetOldest()</title>
        <description> Let me first explain how GetOldest() work right now.

Simply put, it&amp;#039;s a SELECT * FROM geocaches ORDER BY hidden, cacheId LIMIT x
In other words, for those who don&amp;#039;t speak SQL. It fetches limit geocaches ordered by the hidden date, and then the cache-id.

The problem here is that the max limit is 100 (actually it&amp;#039;s 1000, newly changed). Since a challenge must include archived geocaches this causes an issue. If the challenge is to log 20 of the oldest 100, it might be that not all active caches are included. First for the reason that there might be too many archived caches, pushing the active ones outside the limit. It can be assumed that we actually want the 100 oldest that are active, and those older than the newest one. The second issue is that it might be expected that all geocaches from 2004-01-02 is included if one of them are. They are not, since we are cutting hard on the limit.


I have now made a new implementation, which is not released yet. I am looking for feedback.

The new approach is to first figure out the oldest hidden date that falls into the filter. In SQL it&amp;#039;s more like SELECT MAX (hidden) FROM geocaches ORDER BY hidden LIMIT x

And then we make a second run which is then SELECT * FROM geocaches WHERE hidden &amp;lt;= maxHidden ORDER BY hidden (no limit).


So, the question is. Is there anyone who think this approach will be a problem with any current scripts? It seems like some checkers are broken due to an API that has unexpected behaviours. As I see it it can only fix things, though it might change things as well.

If there are any objections, I would like to hear the argument. Based on that we can decide if we will move all current scripts to an obsolete API method or I can just overwrite the current one, or maybe keep both in parallell.</description>
        <link>/forum/read.php?6,7273,7273#msg-7273</link>
        <lastBuildDate>Fri, 17 Apr 2026 18:44:32 +0000</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>/forum/read.php?6,7273,7381#msg-7381</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7381#msg-7381</link>
            <description><![CDATA[ I made another update today. Adding two new options (they are not inside the filters in params).<br />
<ol type="1"><li> dontCountArchivedTowardsLimit: (bool) defaults to true </li><li> dontCountDisabledTowardsLimit: (bool) defaults to false </li></ol>
<br />
With default settings the server code will then figure out the oldest not archived geocache. Then it will return the geocache data for those matching the filters. Ie, it will exclude all archived if that filter-flag has been set.<br />
<br />
This seems to be the expected behaviour, but I am not 100% certain either.<br />
<br />
<br />
If setting dontCountArchivedTowardsLimit to false, the &lt;limit&gt; oldest caches will be returned only. It&#039;s then likely that almost all of them are archived today.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Sat, 18 Feb 2017 16:36:37 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7313#msg-7313</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7313#msg-7313</link>
            <description><![CDATA[ :)<br />
<br />
I assume you noticed it was released.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Thu, 16 Feb 2017 11:55:28 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7312#msg-7312</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7312#msg-7312</link>
            <description><![CDATA[ Wow. What a difference.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Thu, 16 Feb 2017 11:03:46 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7309#msg-7309</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7309#msg-7309</link>
            <description><![CDATA[ I will most likely release the new code tomorrow (~12 hours from now) if there hasn&#039;t been any objections before that. Then we will see what happens.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Wed, 15 Feb 2017 21:59:52 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7307#msg-7307</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7307#msg-7307</link>
            <description><![CDATA[ Those column based databases seem to do wonders.  I had never worked with any.<br />
<br />
You have addressed all my scripts so I foresee no problems. <br />
<br />
Thanks for the speedup. I will worry less about nasty grams from the server admins and cachers who are experiencing timeouts.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Wed, 15 Feb 2017 14:21:05 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7306#msg-7306</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7306#msg-7306</link>
            <description><![CDATA[ sloth96 Wrote:<br />
-------------------------------------------------------<br />
&gt; Just a couple of other variants for your<br />
&gt; benchmarking pleasure.<br />
&gt; <br />
&gt; <a href="http://project-gc.com/Challenges/GC6K6ZV/21974"  rel="nofollow">http://project-gc.com/Challenges/GC6K6ZV/21974</a> <br />
&gt; Run with RetiredGuy or some other world traveller.<br />
&gt; It does a search over oldest by countries.<br />
Current live code: 21, 28, 22<br />
Development code: 31, 20, 20<br />
Seems to average about the same.<br />
<br />
&gt; <a href="http://project-gc.com/Challenges/GC6JF6T/23191"  rel="nofollow">http://project-gc.com/Challenges/GC6JF6T/23191</a><br />
&gt; No recommendation.  It does a search over oldest<br />
&gt; by type. But only in a small part of the world.<br />
Myself, current live code: 17, 16, 16<br />
Myself, development code: 1.9, 4.1, 1.53<br />
Landmaus (German with second most finds), current live code: 22, 24, 23<br />
Landmaus (German with second most finds), development code: 3.0, 2.8, 8.5]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Wed, 15 Feb 2017 08:46:40 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7305#msg-7305</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7305#msg-7305</link>
            <description><![CDATA[ Ah I get it. Generally most likely smart to use GetOldest() on every state there is. The downside is that those really hardcore geocachers won&#039;t benefit from that. They will most likely need almost every state anyway. But in average it will definitely be faster.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Wed, 15 Feb 2017 08:33:49 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7304#msg-7304</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7304#msg-7304</link>
            <description><![CDATA[ Outline for the existing approach for regions goes something like this:<br />
<br />
Get all finds in the relevant area (USA)<br />
<br />
Extract list of regions from finds needed to score the finds<br />
    No need to expend resources where the cacher has not not cached.<br />
<br />
Get the oldest caches in the USA.  (This will contain some number of states oldest caches. More than one.)<br />
      Mingo, GC12, Beverly, The spot, Beaver Cache, Camels Prairie cache are all in the oldest 100 non archived caches.  This gets atleast 6 states without trying really hard. 1000 might have helped find more states. Maybe not. <br />
     <br />
Check for states where the oldest has not been found.<br />
<br />
Loop over states missing from list of finds one at a time changing the filter to one of the states. <br />
      (This is where the request in the other board would have helped.  The hope was again to multiple states in a single call by filtering with a list of regions instead of one at a time.)<br />
       Repeat until bored or we are not finding any more. <br />
<br />
Build table and report results.<br />
<br />
There are a whole bunch of details such as check for caches that have bogus placed dates and other configuration options. <br />
<br />
Also LUA is not on my top 10 programming languages.  You might see some style items from other languages. You might also see the thrashings of a madman trying to get something to work and when it started working well enough, leave it alone, I might break it.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 23:40:39 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7303#msg-7303</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7303#msg-7303</link>
            <description><![CDATA[ Just a couple of other variants for your benchmarking pleasure.<br />
<br />
<a href="http://project-gc.com/Challenges/GC6K6ZV/21974"  rel="nofollow">http://project-gc.com/Challenges/GC6K6ZV/21974</a> <br />
Run with RetiredGuy or some other world traveller. It does a search over oldest by countries.<br />
<br />
<a href="http://project-gc.com/Challenges/GC6JF6T/23191"  rel="nofollow">http://project-gc.com/Challenges/GC6JF6T/23191</a><br />
No recommendation.  It does a search over oldest by type. But only in a small part of the world.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 23:03:52 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7300#msg-7300</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7300#msg-7300</link>
            <description><![CDATA[ I am sorry if I were to heavy on you. Using the word extremely probably sounded like I didn&#039;t like your code, which isn&#039;t the case. Most important, I didn&#039;t mean to offend you.<br />
<br />
Since I took a look at your code I understand that it&#039;s a bit cumbersome because you have been fighting performance issues. It&#039;s of course great that you found a way around that and I appreciate that part.<br />
<br />
My thought were more that if the new api method will be more than 10 times faster, maybe a simpler, dummer, but easier to read script would be better for the future, if/when script changes are required. It&#039;s definitely not necessary to change what&#039;s already in use, and as long as you understand your code I don&#039;t care.<br />
<br />
But for myself, it would be easier to write it from scratch than understanding your optimizations, if I needed a script with slight modifications. I do not mean this as criticism, but IF the new api method will be fast enough, it would be quite fast to write a script with a fairly dumb approach. I am thinking something like this (pseudocode using mixed languages):<br />
<pre class="bbcode">
finds = GetFinds()
foundGccodes = []
foreach(finds as find) {
  if foundGccodes[find.gccode] == nil {
    foundGccodes[find.gccode] = find
  }
}

states = conf.states // all 50 of them
statesCompleted = 0
foreach(states as state) {
  params = {limit: 1, excludeDisabled: true, excludeArchived: true, country = &#039;US&#039;, region: state}
  oldest = GetOldest(params)
  foreach(oldest as old) {
	if(isset(foundGccodes[old])) {
	  statesCompleted++
	}
  }
}

if(statesCompleted &gt;= 10) {
  ok = true
} else {
  ok = false
}</pre>
<br />
I would expect this approach to take 50*0.3*2 seconds. But that might be too long as well. Sounds like 30 seconds which would be much slower than your approach.<br />
<br />
In fact, I never understood your approach really. But it doesn&#039;t matter, I don&#039;t need to. And I didn&#039;t really spend time enough to actually understand it either.<br />
<br />
Anyway. I didn&#039;t mean for you to actually rewrite it. I more meant to present the possibility that a script without hard to understand optimizations might work out after the method changes. I have no intention to criticize any code from anyone, as long as it works as it should.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 21:02:06 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7298#msg-7298</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7298#msg-7298</link>
            <description><![CDATA[ I did not read a single line of wine (edit: I of course mean whine, though I didn&#039;t see any wine either), so we are all good.<br />
<br />
This is exactly the form of feedback I am looking for. If a performance decrease will ruin most checkers using this API method we need to rethink it, and we rather catch it before it&#039;s done. Your feedback made me consider using our columnar based dbms instead, and that improvement feel quite good.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 20:50:48 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7294#msg-7294</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7294#msg-7294</link>
            <description><![CDATA[ Btw, I hope this was the sort of feedback you were seeking. <br />
<br />
Part of me feels that I am whining when there are bigger fish to fry.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 20:13:06 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7293#msg-7293</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7293#msg-7293</link>
            <description><![CDATA[ I am not sure what you mean by extremely more straight forward. Are you saying it needs more comments? <br />
<br />
The code is somewhat convoluted to try to get the runtime down.  It has been a while since I wrote it so I don&#039;t remember all the nastiness at the time. It took a few tries to speed it up to where it is. Timeouts were quite common.Frankly I expected a nasty gram that the checker was too intensive.<br />
<br />
I did put in some other requests to speed it up. They were going to be convoluted as well. <br />
<br />
If the runtime is really 5 seconds then provide me a goal for a rewrite and I will try to meet it. On the flip side, part of me says it ain&#039;t broke so don&#039;t fix it. Part of me also realizes the reporting could improve.  Sorts were eliminated and the like. Not all states get listed unless someone has visited them.<br />
<br />
Just as an aside, there is a corresponding oldest in n country checker that is equally ugly.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 20:04:57 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7292#msg-7292</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7292#msg-7292</link>
            <description><![CDATA[ It seems to be extremely slow. About 100% slower with our new api method.<br />
<br />
I don&#039;t exactly understand the approach though. I started with writing a simple pseudo code that does only this, but after I was done I started to run the SQL queries the api methods would run. Seems like it would take ~50*3.5*2 seconds = 350 seconds.<br />
<br />
It&#039;s surprisingly slow to figure out the oldest geocache in a US state. 3-4 seconds for California, Texas and Ohio, per state. However, I can make a 10 fold optimization for this.<br />
<br />
Not sure how familiar you are with databases, but Project-GC is using both row-based dbms and column based. A column based dbms is much much faster in certain queries, especially those not needing all the data for a row. This is such case. The downside is that our column based dbms is a replica from our row-based, created every 4th (iirc) hour. So the data is always older. But for this specific api method it feels like we don&#039;t care if it&#039;s even two days old.<br />
<br />
Some timings for linked challenged, user sloth96:<br />
Old code = 1.8e+2 seconds<br />
New code = 3.1e+2 seconds<br />
New code using columnar dbms = 5.0 seconds (after some reconfiguring of the engine as well)<br />
<br />
With these changes I also assume the script could be rewritten to be extremely more straight forward?<br />
<br />
PS! No changes are live yet.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 19:48:08 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7287#msg-7287</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7287#msg-7287</link>
            <description><![CDATA[ <a href="http://project-gc.com/Challenges/GC6K9P6/23464"  rel="nofollow">http://project-gc.com/Challenges/GC6K9P6/23464</a> <br />
<br />
This might timeout excessively with the new get oldest.<br />
<br />
My username sloth96 or RetiredGuy shoukd take a while.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 17:26:20 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7285#msg-7285</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7285#msg-7285</link>
            <description><![CDATA[ It doesn&#039;t seem as bad as I thought. I ran a few test cases.<br />
<br />
Old code: 13, 16, 9.8, 9.5, 9.8 seconds. Average: 11.62 seconds<br />
New code: 18, 27, 14, 19, 18 seconds. Average: 19.2 seconds.<br />
<br />
65-66% longer execution time for this particular case. On the other hand, the numbers are so varying that I think it could be a lot more accurate using 2*100 runs.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 15:22:58 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7284#msg-7284</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7284#msg-7284</link>
            <description><![CDATA[ sloth96 Wrote:<br />
-------------------------------------------------------<br />
&gt; I don&#039;t see an obvious problem with that.  The<br />
&gt; checkers I wrote should just loop through the data<br />
&gt; provided. <br />
&gt; <br />
&gt; That bump from 100 to 1000ish may also help<br />
&gt; performance in some of my scripts.  It will pull<br />
&gt; in more regions and or countries and keep me from<br />
&gt; looping as much to get more regions.<br />
&gt; <br />
&gt; The nagging question is does this impact speed<br />
&gt; negatively.  Some of my scripts are on the edge of<br />
&gt; timing things out.<br />
<br />
<br />
It could definitely affect performance. Generally I would say that it&#039;s almost half the speed. We are going from one SQL query to two, and they are almost identical.<br />
<br />
If you can find me an (or a few) example (link + name), I can make a few test runs to see the difference in time. It&#039;s easy for me to compare the development environment with the live servers. It&#039;s definitely interesting to know if this will become an issue.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 14:52:14 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7282#msg-7282</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7282#msg-7282</link>
            <description><![CDATA[ I don&#039;t see an obvious problem with that.  The checkers I wrote should just loop through the data provided. <br />
<br />
That bump from 100 to 1000ish may also help performance in some of my scripts.  It will pull in more regions and or countries and keep me from looping as much to get more regions.<br />
<br />
The nagging question is does this impact speed negatively.  Some of my scripts are on the edge of timing things out.]]></description>
            <dc:creator>sloth96</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 14:15:15 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7281#msg-7281</guid>
            <title>Re: Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7281#msg-7281</link>
            <description><![CDATA[ I don&#039;t see an immediate problem (but I haven&#039;t written any checker with that method).]]></description>
            <dc:creator>pinkunicorn</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 13:31:54 +0000</pubDate>
        </item>
        <item>
            <guid>/forum/read.php?6,7273,7273#msg-7273</guid>
            <title>Rewrite of GetOldest()</title>
            <link>/forum/read.php?6,7273,7273#msg-7273</link>
            <description><![CDATA[ Let me first explain how GetOldest() work right now.<br />
<br />
Simply put, it&#039;s a <pre class="bbcode">SELECT * FROM geocaches ORDER BY hidden, cacheId LIMIT x</pre>
In other words, for those who don&#039;t speak SQL. It fetches <i>limit</i> geocaches ordered by the hidden date, and then the cache-id.<br />
<br />
The problem here is that the max limit is 100 (actually it&#039;s 1000, newly changed). Since a challenge must include archived geocaches this causes an issue. If the challenge is to log 20 of the oldest 100, it might be that not all active caches are included. First for the reason that there might be too many archived caches, pushing the active ones outside the limit. It can be assumed that we actually want the 100 oldest that are active, and those older than the newest one. The second issue is that it might be expected that all geocaches from 2004-01-02 is included if one of them are. They are not, since we are cutting hard on the limit.<br />
<br />
<br />
I have now made a new implementation, which is not released yet. I am looking for feedback.<br />
<br />
The new approach is to first figure out the oldest hidden date that falls into the filter. In SQL it&#039;s more like <pre class="bbcode">SELECT MAX (hidden) FROM geocaches ORDER BY hidden LIMIT x</pre>
<br />
And then we make a second run which is then <pre class="bbcode">SELECT * FROM geocaches WHERE hidden &lt;= maxHidden ORDER BY hidden</pre> (no limit).<br />
<br />
<br />
So, the question is. Is there anyone who think this approach will be a problem with any current scripts? It seems like some checkers are broken due to an API that has unexpected behaviours. As I see it it can only fix things, though it might change things as well.<br />
<br />
If there are any objections, I would like to hear the argument. Based on that we can decide if we will move all current scripts to an obsolete API method or I can just overwrite the current one, or maybe keep both in parallell.]]></description>
            <dc:creator>magma1447</dc:creator>
            <category>Checker news</category>
            <pubDate>Tue, 14 Feb 2017 12:56:35 +0000</pubDate>
        </item>
    </channel>
</rss>
