Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 835735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:52:15+00:00 2026-05-15T04:52:15+00:00

I am reading a table in Python in GAE that has 1000 rows and

  • 0

I am reading a “table” in Python in GAE that has 1000 rows and the program stops because the time limit is reached. (So it takes at least 20 seconds.)(
Is that possible that GAE is that slow? Is there a way to fix that?
Is this because I use free service and I do not pay for it?

Thank you.

The code itself is this:

 liststocks=[]
 userall=user.all() # this has three fields username... trying to optimise by this line
 stocknamesall=stocknames.all() # 1 field, name of the stocks trying to optimise by this line too
 for u in userall: # userall has 1000 users
        for stockname in stocknamesall: # 4 stocks
            astock= stocksowned() #it is also a "table", no relevance I think
            astock.quantity = random.randint(1,100)
            astock.nameid = u.key()
            astock.stockid = stockname.key()
            liststocks.append(astock);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:52:15+00:00Added an answer on May 15, 2026 at 4:52 am

    GAE is slow when used inefficiently. Like any framework, sometimes you have to know a little bit about how it works in order to efficiently use it. Luckily, I think there is an easy improvement that will help your code a lot.

    It is faster to use fetch() explicitly instead of using the iterator. The iterator causes entities to be fetched in “small batches” – each “small batch” results in a round-trip to the datastore to get more data. If you use fetch(), then you’ll get all the data at once with just one round-trip to the datastore. In short, use fetch() if you know you are going to need lots of results.

    In this case, using fetch() will help a lot – you can easily get all your users and stocknames in one round-trip to the datastore each. Right now you’re making lots of extra round-trips to the datastore and re-fetching stockname entities too!

    Try this (you said your table has 1000 rows, so I use fetch(1000) to make sure you get all the results; use a larger number if needed):

    userall=user.all().fetch(1000)
    stocknamesall=stocknames.all().fetch(1000)
    # rest of the code as-is
    

    To see where you could make additional improvements, please try out AppStats so you can see exactly why your request is taking so long. You might even consider posting a screenshot (like this) of the appstats info about your request along with your post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 426k
  • Answers 426k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Wiki says it is an RPC and Solaris-specific at that.… May 15, 2026 at 12:34 pm
  • Editorial Team
    Editorial Team added an answer As long as the procedures/functions are owned by the user… May 15, 2026 at 12:34 pm
  • Editorial Team
    Editorial Team added an answer Hmmm... not so sure... If you install Magento from scratch… May 15, 2026 at 12:34 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.