Re: Navigation question

From: Marshall <marshall.spight_at_gmail.com>
Date: 16 Feb 2007 12:42:35 -0800
Message-ID: <1171658555.209942.301290_at_l53g2000cwa.googlegroups.com>


On Feb 16, 10:11 am, "dawn" <dawnwolth..._at_gmail.com> wrote:
> On Feb 16, 10:48 am, "Marshall" <marshall.spi..._at_gmail.com> wrote:
> > On Feb 16, 8:34 am, "dawn" <dawnwolth..._at_gmail.com> wrote:
>
> > > On Feb 16, 9:48 am, "Marshall" <marshall.spi..._at_gmail.com> wrote:
>
> > > Only a second to scan before heading out, but it appears that you are
> > > still thinking I'm splitting queries and making more round trips and I
> > > am not. Please re-read the example you gave and the one I gave. They
> > > have the same number of queries. How many times do I have to say that
> > > I am not, not, not, absolutely not suggesting that we do more round
> > > trips or split queries. Can you point me to where I have apparently
> > > mistakenly suggested such at thing? --dawn
>
> > Would you be willing to acknowledge that in the real-world
> > case I've described the navigational approach is vastly
> > slower?
>
> > Marshall
>
> Yes, yes, absolutely, but from my perspective that has nothing to do
> with it being "navigational" but in taking more round-trips.

If navigation and iteration are independent, then you ought to be able to rewrite my navigational, iterative pseudocode into a style that is navigational but not iterative, and has roughly the same network performance as the SQL I proposed. Please either 1) do so or 2) acknowledge that iteration and navigation are not in fact independent.

Here's the problem again.

In pseudocode:

ccount = count of customers
declare spend[ccount] = all zeroes
declare max[ccount] = all zeroes
declare item[ccount] = all zeroes
fetch all customer ids
for each customer c
  fetch all invoices ids for customer c
  for each invoice i
    fetch all lineitem count, cost, item for i     for each lineitem l

      spend[c] = spend[c] + l.count * l.cost
      if (l.count > max[c])
        item[c] = l.item

    end

  end
end

Or, in sql:

select c.customerid, sum(l.count*l.cost), max(l.count)   from customers c natural join
    invoices i natural join
    lineitems l

> Do you agree that navigating is not inherently a bad thing?

I try not to think in terms of "good and bad." Code has attributes like performance characteristics, not goodness or badness. Navigation is lower-level than declaration. Whether a lower level approach is appropriate or not is situation dependent. In general device drivers require a very low level of thinking, for example.

Marshall Received on Fri Feb 16 2007 - 21:42:35 CET

Original text of this message