[openstreetmap/openstreetmap-website] Avoid using partial rendering in /map.json (PR #4141)
mmd
notifications at github.com
Fri Jun 28 20:59:08 UTC 2024
Regarding N+1 queries, I tried a gem called 'bullet', which needs a bit of config in config/environments/development.rb:
```
config.after_initialize do
#Enable bullet in your application
Bullet.enable = true
Bullet.rails_logger = true
end
```
It would then complain about N*1 queries, or suggest to remove eager loading where not needed.
```
GET /changeset/127673
USE eager loading detected
OldRelation => [:redaction]
Add to your query: .includes([:redaction])
Call stack
```
As an example, the suggested changes to "changeset_controller.rb - show" would be to add additional :includes for old_nodes/ways/relations: `:include => [:old_tags, :redaction]`
```
@node_pages, @nodes = paginate(:old_nodes, :include => [:old_tags, :redaction], :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "node_page")
@way_pages, @ways = paginate(:old_ways, :include => [:old_tags, :redaction], :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "way_page")
@relation_pages, @relations = paginate(:old_relations, :include => [:old_tags, :redaction], :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "relation_page")
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4141#issuecomment-2197651282
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4141/c2197651282 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240628/dadba7f1/attachment.htm>
More information about the rails-dev
mailing list