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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:50:18+00:00 2026-05-20T18:50:18+00:00

I have two tables: mysql> desc myps3t_gameusertrophyinfo; +———–+————–+——+—–+———+—————-+ | Field | Type | Null

  • 0

I have two tables:


mysql> desc myps3t_gameusertrophyinfo;

+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| id        | int(11)      | NO   | PRI | NULL    | auto_increment |
| user_id   | int(11)      | NO   | MUL | NULL    |                |
| trophy_id | int(11)      | NO   | MUL | NULL    |                |
| date      | datetime     | NO   | MUL | NULL    |                |
| date_read | varchar(100) | NO   |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+
5 rows in set (0.19 sec)


mysql> show index from myps3t_gameusertrophyinfo;

+---------------------------+------------+------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table                     | Non_unique | Key_name                           | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+---------------------------+------------+------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| myps3t_gameusertrophyinfo |          0 | PRIMARY                            |            1 | id          | A         |     4004589 |     NULL | NULL   |      | BTREE      |         |
| myps3t_gameusertrophyinfo |          0 | user_id                            |            1 | user_id     | A         |        7686 |     NULL | NULL   |      | BTREE      |         |
| myps3t_gameusertrophyinfo |          0 | user_id                            |            2 | trophy_id   | A         |     4004589 |     NULL | NULL   |      | BTREE      |         |
| myps3t_gameusertrophyinfo |          1 | myps3t_gameusertrophyinfo_403f60f  |            1 | user_id     | A         |        7686 |     NULL | NULL   |      | BTREE      |         |
| myps3t_gameusertrophyinfo |          1 | myps3t_gameusertrophyinfo_61a683d8 |            1 | trophy_id   | A         |       22624 |     NULL | NULL   |      | BTREE      |         |
| myps3t_gameusertrophyinfo |          1 | idx_gameusertrophyinfo_date        |            1 | date        | A         |     4004589 |     NULL | NULL   |      | BTREE      |         |
+---------------------------+------------+------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
7 rows in set (0.06 sec)

the other table:



mysql> desc myps3t_gametrophyinfo ;
+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| id        | int(11)      | NO   | PRI | NULL    | auto_increment |
| game_id   | int(11)      | NO   | MUL | NULL    |                |
| name      | varchar(500) | NO   |     | NULL    |                |
| desc      | varchar(500) | NO   |     | NULL    |                |
| type      | varchar(20)  | NO   |     | NULL    |                |
| pic_url   | varchar(200) | NO   |     | NULL    |                |
| desc_pt   | varchar(500) | NO   |     | NULL    |                |
| name_pt   | varchar(500) | NO   |     | NULL    |                |
| hidden_id | int(11)      | NO   |     | NULL    |                |
| total_id  | int(11)      | NO   |     | NULL    |                |
| trophy_id | int(11)      | NO   |     | NULL    |                |
| addon_id  | int(11)      | YES  |     | NULL    |                |
| points    | double       | NO   |     | 0       |                |
| sony_id   | int(11)      | YES  |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+
14 rows in set (0.00 sec)

mysql> show index from myps3t_gametrophyinfo;
+-----------------------+------------+-------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table                 | Non_unique | Key_name                      | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------------------+------------+-------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| myps3t_gametrophyinfo |          0 | PRIMARY                       |            1 | id          | A         |       25976 |     NULL | NULL   |      | BTREE      |         |
| myps3t_gametrophyinfo |          1 | myps3t_gametrophyinfo_game_id |            1 | game_id     | A         |         764 |     NULL | NULL   |      | BTREE      |         |
+-----------------------+------------+-------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+

when i do this query:



mysql> explain select * from myps3t_gameusertrophyinfo a, myps3t_gametrophyinfo b  where a.trophy_id = b.id and b.addon_id = 58;                                        +----+-------------+-------+--------+--------------------------------------------------------------+---------+---------+-----------------------------+---------+-------------+
| id | select_type | table | type   | possible_keys                                                | key     | key_len | ref                         | rows    | Extra       |
+----+-------------+-------+--------+--------------------------------------------------------------+---------+---------+-----------------------------+---------+-------------+
|  1 | SIMPLE      | a     | ALL    | myps3t_gameusertrophyinfo_61a683d8,myps3t_gameusertrophyinfo | NULL    | NULL    | NULL                        | 4004592 |             |
|  1 | SIMPLE      | b     | eq_ref | PRIMARY                                                      | PRIMARY | 4       | fabriciols_ps3t.a.trophy_id |       1 | Using where |
+----+-------------+-------+--------+--------------------------------------------------------------+---------+---------+-----------------------------+---------+-------------+
2 rows in set (0.00 sec)

why mysql do not use my keys ?
this query take more than 30 seconds, the first table has 4milion records …

— edit —

for quasnoi



mysql> SELECT COUNT(*), COUNT(DISTINCT addon_id), SUM(addon_id = 58) FROM myps3t_gametrophyinfo;
+----------+--------------------------+--------------------+
| COUNT(*) | COUNT(DISTINCT addon_id) | SUM(addon_id = 58) |
+----------+--------------------------+--------------------+
|    25976 |                      160 |                  6 |
+----------+--------------------------+--------------------+
1 row in set (0.00 sec)
  • 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-20T18:50:19+00:00Added an answer on May 20, 2026 at 6:50 pm

    MySQL chooses a as a leading table and b as a driven table. It does use a PRIMARY KEY on b for the joins.

    Create an index on myps3t_gametrophyinfo (addon_id), this way b will be more probably chosen as a leading table.

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

Sidebar

Related Questions

I have this two tables: mysql> desc vat_rates; +-------------+---------------+------+-----+---------+-------+ | Field | Type |
I have the follow two mysql tables: mysql> desc subscriptions; +------------+--------------+------+-----+---------+----------------+ | Field |
I have two mysql tables - a sales table: +----------------+------------------------------+------+-----+---------+-------+ | Field | Type
i have two mysql tables tableA colA1 colA2 1 whatever 2 whatever 3 whatever
I have two MySQL tables, and I want to find and replace text strings
I have two mysql tables and i want to merge the results of these
I have two MySQL tables: stats (left) and messages (right) +------------+---------+ +---------+------------+-----------+----------+ | _date
I have two tables in a MySql DB: items id (char) name (varchar) description
I have two tables in a MySql database: COUNTRY --------------- id, country_name and CITY
I have two large tables in MySQL, one containing about 6,00,000 records and another

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.