Alternative to ActiveRelationResource which does not produce extra DB queries
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rails, ruby
- Lĩnh vực
- database, performance
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi đường dẫn không được cache của ActiveRelationResource đối với các request có include và so sánh với các query log của 0.9 và 0.10 được hiển thị ở đây. Công việc được xem là hoàn tất khi một phương án thay thế hoặc tối ưu hóa tránh được các query bổ sung về relation và id mà không caching, đồng thời vẫn giữ nguyên các record được include và hành vi phân trang.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This issue is a (choose one):
- Problem/bug report.
- Feature request.
- Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.
Checklist before submitting:
- I've searched for an existing issue.
- I've asked my question on Gitter and have not received a satisfactory answer.
- I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
- The feature I'm asking for is compliant with the JSON:API spec.
Description
One thing that changed significantly in 0.10 is the introduction of ActiveRelationResource, which seems to be a nice optimization to have when caching is utilized. But when caching is not turned on it actually doubles the amount of DB queries needed to process a request. For example, typical request with include would look something like this in the log on 0.10.x:
DEBUG -- : (0.0ms) SELECT "users"."id" AS "users_id", "users"."id" FROM "users" ORDER BY users.id asc LIMIT ? OFFSET ? [["LIMIT", 10], ["OFFSET", 0]]
DEBUG -- : (0.1ms) SELECT DISTINCT users.id AS "source_id", "profiles"."id" AS "profiles_id", "profiles"."id" FROM "users" INNER JOIN "profiles" ON "profiles"."user_id" = "users"."id" WHERE "users"."id" IN (?, ?, ?) ORDER BY profiles.id asc [["id", 1], ["id", 2], ["id", 3]]
DEBUG -- : (0.0ms) SELECT DISTINCT users.id AS "source_id", "posts"."id" AS "posts_id", "posts"."id" FROM "users" INNER JOIN "posts" ON "posts"."user_id" = "users"."id" WHERE "users"."id" IN (?, ?, ?) ORDER BY posts.id asc [["id", 1], ["id", 2], ["id", 3]]
DEBUG -- : User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?, ?) [["id", 1], ["id", 2], ["id", 3]]
DEBUG -- : Profile Load (0.0ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."id" IN (?, ?, ?) [["id", 1], ["id", 2], ["id", 3]]
DEBUG -- : Post Load (0.0ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" IN (?, ?, ?, ?, ?, ?, ?, ?, ?) [["id", 1], ["id", 2], ["id", 3], ["id", 4], ["id", 5], ["id", 6], ["id", 7], ["id", 8], ["id", 9]]
DEBUG -- : (0.0ms) SELECT COUNT(*) FROM "users"
Compare to the same request on 0.9:
DEBUG -- : User Load (0.0ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT ? OFFSET ? [["LIMIT", 10], ["OFFSET", 0]]
DEBUG -- : Profile Load (0.1ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" IN (?, ?, ?) [["user_id", 1], ["user_id", 2], ["user_id", 3]]
DEBUG -- : Post Load (0.0ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (?, ?, ?) [["user_id", 1], ["user_id", 2], ["user_id", 3]]
DEBUG -- : (0.0ms) SELECT COUNT(*) FROM "users"
Is there a plan to optimize non-cached scenario? Like having an alternative base resource that I'd behave more or less like 0.9 behaved? Thanks.
- Ngôn ngữ chính
- Ruby
- Star
- 2.3k
- Fork
- 546
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JSONAPI-Resources/jsonapi-resources
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
ArgumentError with Rails 8.1 Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
JSONAPI-Resources/jsonapi-resources#1488 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
JSONAPI-Resources/jsonapi-resources#1479 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
JSONAPI-Resources/jsonapi-resources#1477 · 3 bình luận · 1 reaction ·
-
Fields filtering with include Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Tất cả issue của JSONAPI-Resources/jsonapi-resources
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
riscv/riscv-unified-db#2626 ·
-
Component: GLib
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
ds-drift
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
we-promise/sure#3693 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
simp/pupmod-simp-simp#395 ·