Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django ORM Basic ORM Usage Restricting Results

Nursultan Bolatbayev
Nursultan Bolatbayev
16,774 Points

What SQL query time depends on?

My SQL query time is totally different that Kenneth's SQL query time in the video. And it differs everytime. On what parameters actually depend SQL query? SQL query time is calculated only from actual webserver to databaser server or it also includes time from my browser to webserver?

Derrick Kearney
Derrick Kearney
2,962 Points

3 months and not one comment....other than this one.

Sergio Cruz
Sergio Cruz
15,550 Points

The way it works in a deployed site is the request is first send from your computer to the application layer server. This will take some X amount of time. Then the application layer (Django) will process the request and use its' ORM to fetch data from the database server. The time for the connection between database server and webserver will take Y amount of time. Then there's the time the database server actually takes in processing your query and fetching data from disk. If that data was in Ram it'll be faster, if it has to read from disk it'll take longer.

In your case I imagine you're running everything on a local development environment. So things differ a bit. Your browser and application layer server are running in the same 'box' or your computer, so there's no connecting time there. If you can show me your queries and the time they're taking I could give you a better answer.