Handling big result sets
Sometime it is needed to handle a lot of rows on client side. Usual way is send query via mysql_query and than handle the result in loop mysql_fetch_array (here I use PHP functions but they are common or similar for all APIs, including C).
Consider table:
-
CREATE TABLE `longf` (
-
`f1` int(11) NOT NULL AUTO_INCREMENT,
-
`f2` date DEFAULT NULL,
-
`f3` date DEFAULT NULL,
-
`f4` varchar(14) DEFAULT NULL,
-
`f5` varchar(6) DEFAULT NULL,
-
`f6` date DEFAULT NULL,
-
`f7` smallint(6) DEFAULT NULL,
-
`f8` smallint(6) DEFAULT NULL,
-
`f9` varchar(13) DEFAULT NULL,
-
`f10` varchar(39) DEFAULT NULL,
-
`f11` int(11) DEFAULT NULL,
-
`f12` float DEFAULT NULL,
-
`f13` int(11) DEFAULT NULL,
-
`f14` smallint(6) DEFAULT NULL,
-
`f15` varchar(39) DEFAULT NULL,
-
`f16` date DEFAULT NULL,
-
`f17` smallint(6) DEFAULT NULL,
-
`f18` int(11) NOT NULL,
-
`f19` date DEFAULT NULL,
-
`f20` date DEFAULT NULL,
-
`f21` varchar(14) DEFAULT NULL,
-
`f22` varchar(6) DEFAULT NULL,
-
`f23` date DEFAULT NULL,
-
`f24` smallint(6) DEFAULT NULL,
-
`f25` smallint(6) DEFAULT NULL,
-
`f26` varchar(13) DEFAULT NULL,
-
`f27` varchar(39) DEFAULT NULL,
-
`f28` int(11) DEFAULT NULL,
-
`f29` float DEFAULT NULL,
-
`f30` int(11) DEFAULT NULL,
-
`f31` smallint(6) DEFAULT NULL,
-
`f32` varchar(39) DEFAULT NULL,
-
`f33` date DEFAULT NULL,
-
`f34` smallint(6) DEFAULT NULL,
-
`f35` int(11) NOT NULL,
-
PRIMARY KEY (`f1`)
-
);
-
-
SELECT count(*) FROM longf;
-
+----------+
-
| count(*) |
-
+----------+
-
| 5242880 |
-
+----------+











del.icio.us
digg