joshblevins's avatar

Calculating Large Data Sets

I'm sure the answer is right in front of my face however I've worked on this for about a week and it is working but when loading the report it takes about 5 minutes to load.

Table Setup User Table id signature ->related to study table

Study table id studyDateTime signature siteId modalityId

Site Table id name

Modalities Table id

Currently I am running the queries inside the view to get the count of studies for the user per site broken down by modality.

What I am trying to figure out is what is the best way to achieve this I've tried relating with has many through and could not get the intended result in the end. Ive considered a piviot table as well.

0 likes
2 replies
Glukinho's avatar

Can you format the text properly and show the code you tried?

jlrdw's avatar

You could workout a grouping, just example here, something like:

$quy = Powner::query()->leftJoin('dc_pets', 'dc_powners.ownerid', '=', 'dc_pets.ownerid')
                ->select('dc_powners.ownerid', 'dc_powners.oname')
                ->selectRaw('count(dc_pets.petid) as countOfPets')
                ->groupby('dc_powners.ownerid')
                ->orderby('dc_powners.oname')
                ->get();

Results basically give:

ownerid, oname, countOfPets

Like:

5|Bob|3
4|Greg|9
2|Rob|1

Just some test data I use.

Please or to participate in this conversation.