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

  • Home
  • SEARCH
  • 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 7039827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:50:43+00:00 2026-05-28T01:50:43+00:00

Has anyone had difficulty with this type of api call: projects.annotate(votes_count=Count(‘votes’)).order_by(‘votes_count’) It’s excruciatingly slow

  • 0

Has anyone had difficulty with this type of api call:

projects.annotate(votes_count=Count('votes')).order_by('votes_count') 

It’s excruciatingly slow for me and I found this related issue:

https://code.djangoproject.com/ticket/17144

I’m wondering if anyone else is experiencing issues related to this or has good work arounds? It seems like a common enough api call that I’m surprised the bug doesn’t have more traction.

  • 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-28T01:50:43+00:00Added an answer on May 28, 2026 at 1:50 am

    The ticket specifically mentions MySQL. I’m using PostgreSQL and use annotations all the time with no noticeable slowness. However, I’ve never specifically checked the generated SQL to see if it’s doing the same thing.

    If you are using MySQL, it would seem you potentially have the following choices (albeit, none of them particular awesome):

    1. Switch over to PostgreSQL. If my anecdotal evidence and the lack of complaints regarding PostgreSQL in the ticket are any indication, it might not be a problem then.

    2. Live with it for now, upgrade to 1.4 when it’s released.

    3. Run off of trunk to get the fix now (not generally a good idea) or try to patch your current installation.

    4. Use raw() as @jknupp suggests.

    4 is probably the easiest and best approach for the moment. It’s not really a problem unless you switch database engines at some point in the future, and you can always just make a note to yourself in the code to do it the right way when Django is updated. I typically do something like the following in similar scenarios:

    """Django has a bug in version 1.3 (see ticket:
    https://code.djangoproject.com/ticket/17144), resulting in unnecessary fields
    being included in the GROUP BY clause and subsequently very slow queries. The raw
    query below can be replaced with the commented line once the issue has been
    corrected.
    """
    # projects.annotate(votes_count=Count('votes')).order_by('votes_count')
    projects.raw(...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone had this problem? I deleted a column in the table editor and
Has anyone had this unusual(recurring) experience before? I'm trying to check out the project
Has anyone had difficulty getting what has otherwise been a solid iPhone app working
Has anyone had issues with this code... ABRecordRef person = ABAddressBookGetPersonWithRecordID (addressBook,recordID); I have
Has anyone had this issue when i pull data out from the database it
Has anyone had any luck with a vba macro that would convert this input:
Has anyone had any experience in saving app preferences (within app, not in Settings
Has anyone had any experiences developing large Java applications using GNU gettext for internationalization?
Has anyone had any experience using Adobe Air to create BitTorrent application? Is there
Has anyone had any experience writing a web control (in either ASP.net, or javascript/HTML/CSS),

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.