pingthepeople / ptp-web

Web front-end for Ping the People
https://pingthepeople.org
2 stars 0 forks source link

N+1 queries #2

Closed jhoerr closed 7 years ago

jhoerr commented 7 years ago

The app is generating a couple N+1 queries in the My Bills view. These may also be present in the All Bills view.

  1. When associating Subjects with Bills:

(@P1 nvarchar(4)) select [Subject].* , [BillSubject].[BillId] as [pivot_BillId] , [BillSubject].[SubjectId] as [pivot_SubjectId] from [Subject] inner join [BillSubject] on [Subject].[Id] = [BillSubject].[SubjectId] where [BillSubject].[BillId] in (@P1)

  1. When associating Actions with Bills:

(@P1 nvarchar(3)) select * from [Action] where [Action].[BillId] in (@P1) order by [Date] desc

  1. When associating ScheduledActions with Bills

(@P1 nvarchar(3),@P2 nvarchar(23)) select * from [ScheduledAction] where [ScheduledAction].[BillId] in (@P1) and [Date] >= @P2 order by [Date] asc

jhoerr commented 7 years ago

Fixed in c8f00933f99f16937ed98a74a8bd8463e02c3396. Profiling has been introduced to prevent future occurrences.