in Education by
I am facing issue of very slow result. I am sharing table structure as and results also. if you have any suggestion please update soon if possible for you. ================================================================= Table Structure -- https://www.phpmyadmin.net/ -- -- Host: localhost:3306 -- Generation Time: Mar 25, 2019 at 11:48 AM -- Server version: 5.5.61-cll -- PHP Version: 7.2.7 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; -- -- Database: `energe3c_lms` -- -- -------------------------------------------------------- -- -- Table structure for table `user_material` -- CREATE TABLE `user_material` ( `id` int(11) NOT NULL, `user_course_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `material_id` int(11) NOT NULL, `attempt` int(11) NOT NULL, `another_attempt` tinyint(1) DEFAULT '0', `status` varchar(255) DEFAULT NULL, `complete` tinyint(1) DEFAULT NULL, `percent` float DEFAULT '0', `time` varchar(255) DEFAULT NULL, `marking_time` varchar(255) DEFAULT NULL, `marked_by` int(11) DEFAULT NULL, `feedback` text, `submitted_date` datetime DEFAULT NULL, `marking_date` datetime DEFAULT NULL, `created` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Indexes for dumped tables -- -- -- Indexes for table `user_material` -- ALTER TABLE `user_material` ADD PRIMARY KEY (`id`), ADD KEY `user_material-user` (`user_id`), ADD KEY `user_material-material` (`material_id`), ADD KEY `user_material-marking-user` (`marked_by`), ADD KEY `user_course-user_material` (`user_course_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `user_material` -- ALTER TABLE `user_material` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- Constraints for dumped tables -- -- -- Constraints for table `user_material` -- ALTER TABLE `user_material` ADD CONSTRAINT `user_course-user_material` FOREIGN KEY (`user_course_id`) REFERENCES `user_course` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `user_material-marking-user` FOREIGN KEY (`marked_by`) REFERENCES `user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, ADD CONSTRAINT `user_material-material` FOREIGN KEY (`material_id`) REFERENCES `material` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `user_material-user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; COMMIT; Showing rows 0 - 24 (25586268 total, Query took 0.0007 seconds.) SELECT * FROM user_material ================================================================= Showing rows 0 - 24 (77 total, Query took 22.9434 seconds.) SELECT * FROM user_material where status='submitted' ================================================================= Showing rows 0 - 24 (34026300 total, Query took 24.4978 seconds.) [submitted_date: ... - ...] SELECT * FROM user_material ORDER BY submitted_date ASC ================================================================= If You have any suggestion, please update me. I am using this query in yii2 framework JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For this query: SELECT * FROM user_material WHERE status = 'submitted'; You want an index on user_material(status). For this query: SELECT * FROM user_material ORDER BY submitted_date ASC You want an index on user_material(submitted_date). In both these cases, additional columns can be in the index after the one specified as the first column. I do not see these indexes in your schema.

Related questions

0 votes
    How to enable slow query log MySQL?...
asked Aug 20, 2021 in Technology by JackTerrance
0 votes
    How can we stop Slow Query Log in MySQL?...
asked Aug 20, 2021 in Technology by JackTerrance
0 votes
    I'm fairly new to python and web-scraping in general. The code below works but it seems to be ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have an EC2 instance (medium, us-east-1d), and RDS instance (us-east-1a, db.t2.medium). I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I'm trying to enable Slow Query Logging on mysql 5.7 and getting this error: 2016-04-27T14:55:51 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I have a very large MySQL table (billions of rows, with dozens of columns) I would like to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    In my database I have some records where I am sorting by a column that contains identical values: | ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    Which component do you need in order to prevent an unwanted commit in MySQL database? tMysqlRollback tMysqlCommit tMysqlLookupInput tMysqlRow...
asked Mar 25, 2021 in Technology by JackTerrance
0 votes
    Based on solute - solvent interactions, arrange the following in order of increasing solubility in n- octane and ... CHM3OH,CHM3CN . Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    Which of the following specifies the required minimum number of observations for each column pair in order to ... and answers pdf, Data Science interview questions for beginners...
asked Oct 29, 2021 in Education by JackTerrance
0 votes
    I'm trying to produce a page that would function a bit like a digital sticker album. My SQL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    Why does this mysql query fail? UPDATE accounts SET motivation = IF(motivation+100...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I would like to implement a very small and simple group chat into my website without using any 3rd party ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
...