Tables Optimization
Hello team,
We have 2 tables. tableA with 7,285,239 rows and tableB with 178,921,615 rows.
We have to join these 2 tables and use Distinct and ORDER BY 2 columns.
We have added the required indexes in both the tables.
It is taking more than 15 seconds to show the response in the UI.
Please let us know how to optimize this query.
Table1 is having 75 columns.
Table2 DDL
CREATE TABLE `Table2` (
`Id` bigint NOT NULL AUTO_INCREMENT,
`FolderId` int NOT NULL,
`Table1_Id` bigint NOT NULL,
`ParentTable1_Id` bigint DEFAULT NULL,
PRIMARY KEY (`Id`),
KEY `IX_Table2_Table1_Id` (`Table1_Id`),
KEY `IX_Table2_FolderId` (`FolderId`),
KEY `IX_Table2_ParentTable1_Id` (`ParentTable1_Id`),
CONSTRAINT `FK_Table2_Table1_Table1_Id` FOREIGN KEY (`Table1_Id`) REFERENCES `Table1` (`Id`) ON DELETE RESTRICT,
CONSTRAINT `FK_Table2_Folders_FolderId` FOREIGN KEY (`FolderId`) REFERENCES `Folders` (`Id`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Subject
Written By
Posted
Tables Optimization
April 20, 2025 09:24PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.