[OSM-dev] API Logic

Tom Hughes tom at compton.nu
Fri Jan 25 19:19:25 GMT 2008


On 25/01/2008, SteveC <steve at asklater.com> wrote:

> Richards stuff does a lot of things through mass updates... If I
> delete all the nodes in a way then I dont want to find them all and
> delete them all. You can instead do
>
> Node.delete([1,2,3,4,5])
>
> in rails and so things like
>
> Node.update([1,2,3,4,5], :visible => false, :used_id = 42)
>
> which is one query instead of 100,000 right?

Nope. It might look like it, but it isn't - if you look at the source
you'll see rails does when you do that is look calling update on each
id. That then calls update_attributes for the record, which just
updates self and does save (which will trigger the before_save to
update the tile number).

So do that if you want - it may look the code look nice and tidy - but
tile updating should still work and it is no more efficient than
looping.

Tom

-- 
Tom Hughes (tom at compton.nu)
http://www.compton.nu/




More information about the dev mailing list