Skip to content

api performance with a lot of nested objects #213

Description

@nicolaspernoud

Hi, when using QOR restful API (GET something.json), it seems that if "something" has nested structs which can themselves have nested structs, the API performance is not great (several seconds per request). It seems than instead of doing joined tables requests with the mysql backend, qor does a lot of request on tables and join the data together itself. Is there a way to improve the performance ?

My structs :

type Election struct {
	gorm.Model
	Name      string
	Date      time.Time
	Areas     []Area
	FirstTour bool
}

type Area struct {
	gorm.Model
	Name           string
	ElectionID     uint
	Election       Election
	SeatNumber     uint
	MapId          uint
	Cities         []City
	CandidateLists []CandidateList
}

type City struct {
	gorm.Model
	Name   string
	AreaID uint
	Area   Area
	Desks  []Desk
	MapId  uint
}

type Desk struct {
	gorm.Model
	DeskIdentifier uint
	Name           string
	Subscribed     uint
	CityID         uint
	City           City
	Votes          []Vote
	Completed      bool
	DateCompleted  time.Time
	Validated      bool
}

type Party struct {
	gorm.Model
	Name           string
	Color          string
	CandidateLists []CandidateList
}

type CandidateList struct {
	gorm.Model
	Name       string
	PartyID    uint
	Party      Party
	AreaID     uint
	Area       Area
	Candidates []Candidate
	Votes      []Vote
}

// Candidate
type Candidate struct {
	gorm.Model
	Name                    string
	FirstName               string
	Rank                    uint
	Birthdate               time.Time
	PotentialIcompatibility bool
	Refused                 bool
	Removed                 bool
	CandidateListID         uint
}

// Vote
type Vote struct {
	gorm.Model
	CandidateListID uint
	CandidateList   CandidateList
	DeskID          uint
	Desk            Desk
	VoiceNumber     uint
	Blank           bool
	NullVote        bool
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions