Optimising a Query with 1 million rows

Lubricant Jam

I've been trying to optimise this query I've got, originally I was using INNER JOIN for the vip.tvip database however noticed that people that didn't exist in that table weren't showing and read I have to use a LEFT JOIN which has caused further issues.

SELECT sb_admins.srv_group AS role, rankme.lastconnect, rankme.steam, rankme.name, rankme.pfp, vip.tvip.vip_level FROM bans.sb_admins
INNER JOIN rankme ON CONCAT("STEAM_0:", rankme.authid) = sb_admins.authid
LEFT JOIN vip.tvip ON tvip.playerid = rankme.authid
AND gid > 0 ORDER BY rankme.name;

This is the query I'm currently using, it seems to take around 5 seconds to get the result due to the rankme table being 1.3 million rows. I am also attaching the EXPLAIN for this query too, I'm not that well versed in MySQL queries so apologies if I am butchering this.

EXPLAIN Query

If someone could give an in-sight on how to fix this, would be tremendously helpful. I have created keys for anything which I could such as name being a FULLTEXT key etc but still no prevail.

Cheers.

Luuk

Could you try:

SELECT sb_admins.srv_group AS role, rankme.lastconnect, rankme.steam, rankme.name, rankme.pfp, vip.tvip.vip_level FROM bans.sb_admins
INNER JOIN rankme ON rankme.authid = REPLACE(sb_admins.authid,"STEAM_0:","")
LEFT JOIN vip.tvip ON tvip.playerid = rankme.authid
AND gid > 0 ORDER BY rankme.name;

This should be able to use the index on rankme.authid in rankme. (if that exists...)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Query optimization on a Table with 1 Million rows

Slow Query on Medium MySQL Table (1 Million Rows)

Create clustered or nonclustered index on 1 million rows table for LIKE query?

Optimising table design or optimising the query

Java SQL 1 million rows

Doctrine native query(createNativeQuery) select query for 1 million rows high memory usage

Is there a way to speed up this query for million rows in both t1 and t1?

Psycopg2 - How to Do Large Query - 1 Million Plus Rows

How to query against 18million rows?

SELECT query without FROM clause with a million rows

Query large table with 50 million rows

How to optimize this sql query on + 2 million rows

Optimising postgresql query

Oracle - optimising SQL query

Optimising SQL query

Optimizing SQL query on table of 10 million rows: neverending query

Optimising my SQL Server query

Optimising MySql Query with LEFT JOINS

Optimising PostgreSQL Query that seems slow

Optimising spatial mysql query with point

Update about 1 million rows in MySQL table every 1 hour

Laravel Eloquent Query to 2 Million Rows takes long time

MySql insert into select query is too slow to copy 100 million rows

How to tune a query with aggregations of tables over 15 million rows?

A simple select query taking 8mins on 30 million rows

update query with 1.5 million rows taking long time to execute mysql

10 Million rows taking 3.50 seconds for a simple type query

Optimal MYSQL query for longest prefix matching in a table with 5 million rows

Delete query from million rows table with limit in my sql