AncientSwordRage / nWoD-db

Web app for creating new world of darkness characters and browsing character data (Mage spells, vampire disciplines merits, etc)
1 stars 0 forks source link

Calls to the database are inefficient, and therefore page load is mind-numbingly slow. #11

Closed AncientSwordRage closed 9 years ago

AncientSwordRage commented 9 years ago

It might be that calls to the database are inefficient, not sure if it is due to the N+1 or my over zealous use of link tables.

But 4 seconds to get a JSON from a DB is wrong.

rozza2058 commented 9 years ago

I don't know how much db work you've done before but try and make sure you have indexes on as many tables as you can - it'll make link tables infinitely more efficient.

On Wed, Mar 4, 2015 at 9:46 AM, AncientSwordRage notifications@github.com wrote:

Not sure if it is due to the N+1 http://stackoverflow.com/q/97197/1075247 or my over zealous use of link tables.

But 4 seconds to get a JSON form a DB is wrong.

— Reply to this email directly or view it on GitHub https://github.com/AncientSwordRage/nWoD-db/issues/11.

AncientSwordRage commented 9 years ago

Ill look into it...though I'm not sure it's that big a problem.

image

SQL query seems to take 3ms if Django Toolbar can be trusted. But the TTFB is the long call on the Mages.json.

As for the angular download, I can only guess that's because I'm not using the CDN (?).

rozza2058 commented 9 years ago

Wow, that's a lot of latency! 3.32s TTFB? Why's that happening? 7 seconds to load angular.js? Do you have it local? Because that should be quicker than CDN - is it minified?

On Wed, Mar 4, 2015 at 10:33 AM, AncientSwordRage notifications@github.com wrote:

Ill look into it...though I'm not sure it's that big a problem.

[image: image] https://cloud.githubusercontent.com/assets/5961746/6481937/8d0d7020-c259-11e4-9d2e-a31bd92c43ad.png

SQL query seems to take 3ms if Django Toolbar can be trusted. But the TTFB is the long call on the Mages.json.

As for the angular download, I can only guess that's because I'm not using the CDN (?).

— Reply to this email directly or view it on GitHub https://github.com/AncientSwordRage/nWoD-db/issues/11#issuecomment-77132086 .

AncientSwordRage commented 9 years ago

I thought it was a lot! It's local but not minified. I figured having it non-minfied was better for my education but I have not need it. Does minification add that much?

As for my TTFB is so monstrous, I have no idea.

rozza2058 commented 9 years ago

It should barely add anything on a file by file basis. Good practice when you have lots of files or large files, as it helps UX to have things load quickly. Something about your system is weirdly slow and I don't know enough about it to fix it for you - maybe it's Django?

On Wed, Mar 4, 2015 at 10:36 AM, AncientSwordRage notifications@github.com wrote:

I thought it was a lot! It's local but not minified. I figured having it non-minfied was better for my education but I have not need it. Does minification add that much?

As for my TTFB is so monstrous, I have no idea.

— Reply to this email directly or view it on GitHub https://github.com/AncientSwordRage/nWoD-db/issues/11#issuecomment-77132584 .

AncientSwordRage commented 9 years ago

It's probably Django. Don't worry about fixing it for me though. It might be how it goes from Django -> Rest Framework ->Json, and the reason the SQL is so light is as it's already loaded it, but the transform takes time?

Or it might just be my works network?

AncientSwordRage commented 9 years ago

It's a still a little slow to load the raw json from the api:

image

AncientSwordRage commented 9 years ago

Looking over my DB, I think I've massively over normalised the link between character and ability/skill/arcana.

I'm going to re-write the character models to keep the tables simple.