All,
I'm using this as the conditional to my select statement.
WHERE RecDate >= '%s' GROUP BY DATE(RecDate), HOUR(RecDate), MINUTE(RecDate),
SECOND(RecDate) - (Second(RecDate) \% %d) LIMIT %d
Currently this query is taking a bit too long. What I'm trying to do here is gather X amount of rows after a certain date. I also don't want every row, I want every Nth row, which is what the GROUP section is achieving for me I believe.
Basically I have a bunch of analog signals that are sampled and put into a DB at 1hz (each row.) I don't want to display on a graph about 4-8 hours of data per time, but it doesn't make sense to pull all of the points back.
I'm trying to leverage the database as much as possible. Is there any way I can make this query run faster?
Regards, Ken
Here's the create statement for my table.
DROP TABLE IF EXISTS `vdaq_6`.`readings`;
CREATE TABLE `vdaq_6`.`readings` (
`RigId` varchar(15) NOT NULL DEFAULT '',
`Location` varchar(45) NOT NULL DEFAULT '',
`RecDate` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`0123` double NOT NULL DEFAULT '0',
`0124` double NOT NULL DEFAULT '0',
`0118` double NOT NULL DEFAULT '0',
`0114` double NOT NULL DEFAULT '0',
`0126` double NOT NULL DEFAULT '0',
`0121` double NOT NULL DEFAULT '0',
`0141` double NOT NULL DEFAULT '0',
`0137` double NOT NULL DEFAULT '0',
`1129` double NOT NULL DEFAULT '0',
`0130` double NOT NULL DEFAULT '0',
`0108` double NOT NULL DEFAULT '0',
`0113` double NOT NULL DEFAULT '0',
`0110` double NOT NULL DEFAULT '0',
`0116` double NOT NULL DEFAULT '0',
`0120` double unsigned NOT NULL DEFAULT '0',
`0112` double NOT NULL DEFAULT '0',
`0128` double NOT NULL DEFAULT '0',
`0423` double NOT NULL DEFAULT '0',
PRIMARY KEY (`RigId`,`Location`,`RecDate`),
KEY `Index_2` (`RecDate`),
KEY `replication` (`UpdateCd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='v2;InnoDB free: 523264 kB';