Page 3 of 3
Re: Math Php question
Posted: Thu Nov 27, 2008 8:08 am
by mintedjo
VladSun wrote:mintedjo wrote:VladSun wrote: ... But your expression is wrong

It should be
Code: Select all
ABS(pxls.x - other_pxls.x) + ABS(pxls.y - other_pxls.y)
I know, I followed up with a post correcting that.
Sorry, I didn't see it.
It's ok, we all make mistakes

Re: Math Php question
Posted: Thu Nov 27, 2008 8:54 am
by onion2k
mintedjo wrote:It's ok, we all make mistakes

I don't.

Re: Math Php question
Posted: Thu Nov 27, 2008 9:01 am
by mintedjo
onion2k wrote:mintedjo wrote:It's ok, we all make mistakes

I do...

Re: Math Php question
Posted: Thu Nov 27, 2008 12:04 pm
by VladSun
[sql]SELECT pxls.x, pxls.y, ( SELECT sum(abs(pxls.x - other_pxls.x) + abs(pxls.y - other_pxls.y)) FROM pxls AS other_pxls ) AS distance FROM pxls [/sql]
This query executes in 2.51 sec, but no "ORDER BY distance" is applied. So, you have 9'000'000 result records and you need to find MAX and MIN.
But ...
[sql]SELECT pxls.x, pxls.y, ( SELECT sum(abs(pxls.x - other_pxls.x) + abs(pxls.y - other_pxls.y)) FROM pxls AS other_pxls ) AS distance FROM pxls ORDER BY distanceLIMIT 1[/sql]
is very, very slow.
Re: Math Php question
Posted: Thu Nov 27, 2008 12:05 pm
by VladSun
onion2k wrote:mintedjo wrote:It's ok, we all make mistakes

I don't.

I will be waiting for you to make one
