@tomhughes commented on this pull request.

I suspect you could do this using `in_batches_of` and `with` to construct CTEs 
inside the loop but it might be more hassle than it's worth.

> +      # Find changeset ids to be updated
+      ids_sql = <<~SQL.squish
+        SELECT id
+        FROM changesets
+        WHERE id BETWEEN #{start_id} AND #{end_id}
+          AND (
+            COALESCE(num_created_nodes, 0) +
+            COALESCE(num_modified_nodes, 0) +
+            COALESCE(num_deleted_nodes, 0) +
+            COALESCE(num_created_ways, 0) +
+            COALESCE(num_modified_ways, 0) +
+            COALESCE(num_deleted_ways, 0) +
+            COALESCE(num_created_relations, 0) +
+            COALESCE(num_modified_relations, 0) +
+            COALESCE(num_deleted_relations, 0)
+          ) IS DISTINCT FROM num_changes

None of those columns are nullable so we don't really need the `COALESECE` 
calls and we can use normal comparison rather than `IS DISTINCT FROM`?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6347#pullrequestreview-3148231670
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/6347/review/3148231...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to