title: Simple select query takes more time in very large table in MySQL database in C# application
body: <p>I am using a MySQL database in my ASP.NET with C# web application. The MySQL Server version is 5.7 and there is 8&nbsp;GB RAM in the PC. When I am executing the select query in MySQL database table, it takes more time in execution; a simple select query takes <strong>around 42 seconds</strong>. <strong>Across 1 crorerecord (10 million records) in the table.</strong> I have also done indexing for the table. How can I fix this?</p>
  
  <p>The following is my table structure.</p>
  
  <pre><code>CREATE TABLE `smstable_read` (
      `MessageID` int(11) NOT NULL AUTO_INCREMENT,
      `ApplicationID` int(11) DEFAULT NULL,
      `Api_userid` int(11) DEFAULT NULL,
      `ReturnMessageID` varchar(255) DEFAULT NULL,
      `Sequence_Id` int(11) DEFAULT NULL,
      `messagetext` longtext,
      `adtextid` int(11) DEFAULT NULL,
      `mobileno` varchar(255) DEFAULT NULL,
      `deliverystatus` int(11) DEFAULT NULL,
      `SMSlength` int(11) DEFAULT NULL,
      `DOC` varchar(255) DEFAULT NULL,
      `DOM` varchar(255) DEFAULT NULL,
      `BatchID` int(11) DEFAULT NULL,
      `StudentID` int(11) DEFAULT NULL,
      `SMSSentTime` varchar(255) DEFAULT NULL,
      `SMSDeliveredTime` varchar(255) DEFAULT NULL,
      `SMSDeliveredTimeTicks` decimal(28,0) DEFAULT '0',
      `SMSSentTimeTicks` decimal(28,0) DEFAULT '0',
      `Sent_SMS_Day` int(11) DEFAULT NULL,
      `Sent_SMS_Month` int(11) DEFAULT NULL,
      `Sent_SMS_Year` int(11) DEFAULT NULL,
      `smssent` int(11) DEFAULT '1',
      `Batch_Name` varchar(255) DEFAULT NULL,
      `User_ID` varchar(255) DEFAULT NULL,
      `Year_ID` int(11) DEFAULT NULL,
      `Date_Time` varchar(255) DEFAULT NULL,
      `IsGroup` double DEFAULT NULL,
      `Date_Time_Ticks` decimal(28,0) DEFAULT NULL,
      `IsNotificationSent` int(11) DEFAULT NULL,
      `Module_Id` double DEFAULT NULL,
      `Doc_Batch` decimal(28,0) DEFAULT NULL,
      `SMS_Category_ID` int(11) DEFAULT NULL,
      `SID` int(11) DEFAULT NULL,
      PRIMARY KEY (`MessageID`),
      KEY `index2` (`ReturnMessageID`),
      KEY `index3` (`mobileno`),
      KEY `BatchID` (`BatchID`),
      KEY `smssent` (`smssent`),
      KEY `deliverystatus` (`deliverystatus`),
      KEY `day` (`Sent_SMS_Day`),
      KEY `month` (`Sent_SMS_Month`),
      KEY `year` (`Sent_SMS_Year`),
      KEY `index4` (`ApplicationID`,`SMSSentTimeTicks`),
      KEY `smslength` (`SMSlength`),
      KEY `studid` (`StudentID`),
      KEY `batchid_studid` (`BatchID`,`StudentID`),
      KEY `User_ID` (`User_ID`),
      KEY `Year_Id` (`Year_ID`),
      KEY `IsNotificationSent` (`IsNotificationSent`),
      KEY `isgroup` (`IsGroup`),
      KEY `SID` (`SID`),
      KEY `SMS_Category_ID` (`SMS_Category_ID`),
      KEY `SMSSentTimeTicks` (`SMSSentTimeTicks`)
  ) ENGINE=MyISAM AUTO_INCREMENT=16513292 DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>The following is my select query:</p>
  
  <pre><code>SELECT messagetext, SMSSentTime, StudentID, batchid,
  User_ID,MessageID,Sent_SMS_Day, Sent_SMS_Month,
  Sent_SMS_Year,Module_Id,Year_ID,Doc_Batch
  FROM smstable_read
  WHERE StudentID=977 AND SID = 8582 AND MessageID&gt;16013282
  </code></pre>