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 6912397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:05:14+00:00 2026-05-27T09:05:14+00:00

I pull a range (e.g. limit 72, 24) of games from a database according

  • 0

I pull a range (e.g. limit 72, 24) of games from a database according to which have been voted most popular. I have a separate table for tracking game data, and one for tracking individual votes for a game (rating from 1 to 5, one vote per user per game). A game is considered “most popular” or “more popular” when that game has the highest average rating of all the rating votes for said game. Games with less than 5 votes are not considered. Here is what the tables look like (two tables, “games” and “votes”):

games:
gameid(key)
gamename
thumburl

votes:
userid(key)
gameid(key)
rating

Now, I understand that there is something called an “index” which can speed up my queries by essentially pre-querying my tables and constructing a separate table of indices (I don’t really know.. that’s just my impression).

I’ve also read that mysql operates fastest when multiple queries can be condensed into one longer query (containing joins and nested select statements, I presume).

However, I am currently NOT using an index, and I am making multiple queries to get my final result.

What changes should be made to my database (if any — including constructing index tables, etc.)? And what should my query look like?

Thank you.

  • 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-27T09:05:14+00:00Added an answer on May 27, 2026 at 9:05 am

    Your query that calculates the average for every game could look like:

    SELECT gamename, AVG(rating)
    FROM games INNER JOIN votes ON games.gameid = votes.gameid
    GROUP BY games.gameid
    HAVING COUNT(*)>=5 
    ORDER BY avg(rating) DESC
    LIMIT 0,25
    

    You must have an index on gameid on both games and votes. (if you have defined gameid as a primary key on table games that is ok)

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

Sidebar

Related Questions

I need to pull records from a mysql database which has everything stored as
I need to pull some BLOB data from a SQL Server 2005 database and
I would like to pull artifacts from teamcity. I've been trying to use c#
I need to pull item quantity from a DB2 database from an aspx page
I am designing a query that pull rows from a large table based on
I am using SqlDataSource to pull in information from a table such that only
I have a query that is supposed to pull records from several tables using
I have a small issue. I am trying to pull some data from my
I have a report that pulls information from a summary table and ideally will
I have a Rails named_scope which is using a condition to pull specific days

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.