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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:31:42+00:00 2026-05-11T23:31:42+00:00

I would really appreciate it if some of you could help optimize my tables,

  • 0

I would really appreciate it if some of you could help optimize my tables, as they currently take extremely long to execute because of the following issues:

Main table:

game {
   game_id [PRIMARY KEY]
   *team_id
   *stadium_id
   home_score
   opponent_score
   date
   tour
   half_home_score
   half_opp_score
   attendance
   referee_id
   coach_id
   captain_id
}

players (contains all players that played in the game) {
    *game_id
    *team_id
    *player_id
    position
    number
}

tries, conversions, penalties, dropgoals {
    *player_id
    *game_id
    *team_id
}

team {
    team_id [PRIMARY KEY]
    country
}

player {
    player_id [PRIMARY KEY]
    *team_id
    name
    surname
    fullname
    DOB
    POB
    school
    height
    weight
    position
}

I tend to make all *_id’s of type (UNSIGNED INT[5])? I am a bit unsure if UNSIGNED is needed

All text is VARCHAR(500..200) depending on the size needed

I use DATE type where I can eg. DOB, date

‘ * ‘ – refers to foreign keys that are primary keys in other tables

One page is particularly slow, what happens is the following:

The page shows the lineup of players for the specific game so my queries are the following:

SELECT all player_id’s,number,position FROM players table WHERE game_id is specific game’s id
getTries(player_id,game_id) from tries table
.
.
getDropgoals(player_id,game_id) from dropgoals table

getPlayerName(player_id) from player table

Output to table the received details

<tr>
<td>tries</td>...<td>dropgoals</td><td>position</td><td>player's name</td><td>number</td></tr>

I would really appreciate it if someone could point out some visible pitfalls.

Regards

// edit

I have used the following query, but it only outputs the rows that found in the tries table, I want it to output all players found, but only count the number of tries that he scored, if no tries were scored for that player, it must still output the players details but 0 for tries scored.

I am not sure if my query is correct:
SELECT ps.player_id, ps.position, ps.number, p.name, p.surname, COUNT(*) AS triesNo FROM players ps, player p, tries WHERE p.player_id=ps.player_id AND ps.game_id = ‘$game_id’ AND ps.team_id IS NULL AND tries.player_id = ps.player_id GROUP BY ps.player_id ORDER BY ps.number

I want it to also return a player if he scored no tries, now it only returns the player if he scored a try.

Can anyone help please?

  • 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-11T23:31:43+00:00Added an answer on May 11, 2026 at 11:31 pm

    From the sounds of it you may be (a) running too many queries on a page load, or (b) not joining data on appropriate fields, if you’re selecting from multiple tables at once.

    For example from what you said, you appear to get running a whole set of queries to get player names, but you can merge that with your first query like so:

    SELECT ps.player_id, ps.position, ps.number, p.name
    FROM players ps, player p
    WHERE p.player_id=ps.player_id
    

    That query joins two tables on the player_id, and you end up with an array of players with id/position/number/name.

    You may also want to look into indexes. It’s a good idea to index any field(s) used in a WHERE clause (that aren’t already indexed with a primary key).

    As others have, said, you’ll need to be more specific with what queries are running slow.

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

Sidebar

Related Questions

I would really appreciate some help on this. I have relationships such as: class
I needed some help/pointers on a homework problem. I would really appreciate it if
Hi I would really appreciate some help in forming a regex that removes a
I would really appreciate some help with deleting a file from IsolatedStorage on WP7.
I would really appreciate it, if somebody could help me out with my regular
I'm at a lose end and would really appreciate some help as it is
I am hoping someone could help, and would really appreciate. I am trying to
I would really appreciate any jquery expert help as a method I've used previously,
I would really appreciate if you could shed light on this problem. I have
I would really appreciate if you would take a look at this piece of

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.