I've just noticed that when I export a large table with HeidiSQL the queries in log pane look like this:
SELECT * FROM `database_name`.`very_large_table` LIMIT 759838;
SELECT * FROM `database_name`.`very_large_table` LIMIT 759838, 759838;
SELECT * FROM `database_name`.`very_large_table` LIMIT 1519676, 759838;
In other words, a series of select queries with LIMIT
clause but no ORDER BY
. Unless I'm missing something, that means that HeidiSQL can be happily omitting some rows and exporting other rows several times. Instead, I'd expect to order by a deterministic column set, e.g.:
- Primary key (if exists):
SELECT *
FROM `database_name`.`very_large_table`
ORDER BY server_id, foo_id
LIMIT 1519676, 759838;
- All table rows (otherwise):
SELECT *
FROM `database_name`.`very_large_table`
ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
LIMIT 1519676, 759838;
It might be rare but I've found actual situations where a simple paginator would fail for this same reason.