​Thank you everyone for your continued input on my question! I was pretty
satisfied with the sorting approach but distinct values might be an
interesting approach!

I just ran another test on 240k records first using the approach that sorts
the records and then using the selection to array approach.​ And the
sorting process ran in 7 ticks the first time while the s2a process took 99
ticks with the index loaded. So the sorting approach definitely wins there.

Running again with the data warmed up and changing the sorted S2A to
unsorted DV, the results are a bit surprising. The sorting approach took 4
ticks this time and the distinct values approach, drum roooollllllll, took
1 tick to get Min & Max Dates from 240k records!

So I am converting to the DV, no sorting approach!

My code which allows me to extract Min, Max or both:

$pField:=$1
DISTINCT VALUES($pField->;arDates)
If (Defined ($2))

$pDate_min:=$2

$pDate_min->:=arDates{1}

End if
If (Defined ($3))

$pDate_max:=$3

$pDate_max->:=arDates{Size of array(arDates)}

End if


The Defined method is just $0:=Not(Undefined($1))

Thanks again, 8o)
Alan


On Thu, Oct 12, 2017 at 4:00 PM, David Adams via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> On Thu, Oct 12, 2017 at 6:57 AM, Arnaud de Montard via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
>
> >
> > It's a solution if the selection is huge (is it?). But sort selection
> > (I've always found 4d sort is slow), then 2 selection to array, that's 3
> > server calls, at end. I'd prefer selection to array (1 call), sort array,
> > read first and last items in array.
> >
>
> Agreed. I'd want to know that there is any optimization needed past FIRST
> RECORD and LAST RECORD before diving into anything else. And, past that,
> you would want to balance the cost of pulling more data over the network in
> once call with pulling tiny bits of data over the network with multiple
> calls.
>
> I suspect this is getting a bit silly, but another idea is to have an
> method set to "Execute on server" that does the work and packs the results
> in an object and returns it. Yeah, that might work.
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************
>
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to