Open
Conversation
added 2 commits
February 16, 2025 10:45
spajic
approved these changes
Feb 18, 2025
| gem 'bootsnap' | ||
| gem 'rack-mini-profiler' | ||
| gem 'activerecord-import' | ||
| gem 'pghero' |
| <%= render "delimiter" %> | ||
| <% end %> | ||
|
|
||
| <%= render partial: "trip", collection: @trips %> No newline at end of file |
| <% if trip.bus.services.present? %> | ||
| <li>Сервисы в автобусе:</li> | ||
| <ul> | ||
| <%= render partial: "service", collection: trip.bus.services %> |
| <%= render "services", services: trip.bus.services %> | ||
| <% end %> | ||
| </ul> | ||
| <%= render "delimiter" %> |
Collaborator
There was a problem hiding this comment.
кажется делимитер потерялся
его тоже можно параметров в render collection задать, https://guides.rubyonrails.org/layouts_and_rendering.html#spacer-templates
|
|
||
|
|
||
| ### Ваша находка | ||
| - запустил импорт exmaple.json файла и начал смотреть логи |
Collaborator
There was a problem hiding this comment.
как говорит Nate Berkopec, если бы все смотрели логи, у меня бы не было работы
| + так же пришлось для удобсва создать можель на связь BusesService | ||
| + все объекты сохранял сразу в переменную и hash | ||
| ``` | ||
| to = cities[trip['to']] ||= City.new(name: trip['to']) |
|
|
||
| ## Результаты | ||
| - В результате проделанной оптимизации наконец удалось обработать файл с данными и уложиться в поставленные нами метрики. | ||
| - Удалось улучшить отрисовку страницы расписаний с 11.3с до 0.3с. |
| SELECT "trips".* FROM "trips" WHERE "trips"."from_id" = $1 AND "trips"."to_id" = $2 ORDER BY "trips"."start_time" ASC; | ||
| ``` | ||
| 2) добавил индекс на фильтруемые данные сразу отсортированные | ||
| `add_index :trips, %i[from_id to_id start_time], order: {start_time: :asc}, algorithm: :concurrently` |
Collaborator
There was a problem hiding this comment.
я бы start_time не стал в этот составной индекс добавлять
[from_id, to_id] можно, а start_time лучше отдельно
| ``` | ||
|
|
||
| но так же прибавил в памяти, для нас пока не влияет но надо учитывать index_trips_on_from_id_and_to_id_and_start_time 2.19 MB. | ||
| Выйгрыш по скорости не такой большой |
Collaborator
There was a problem hiding this comment.
в данном случае маленькая изначально доля уходит на выполнение этого SQL-запроса, поэтому выигрыша большого не может быть
но если бы мы заходили с точки зрения оптимизации БД, то там бы это очень помогло
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.