I have a situation where I need to use a huge number for the limit. For example,
"select * from a table limit 15824293949,1";
this is….really really slow. Sometimes my home mysql server just dies.
is it possible to make it faster?
sorry the number was 15824293949, not 38975901200
Added:
**Table 'photos' (Sample)** Photos img_id img_filename 1 a.jpg 2 b.jpg 3 c.jpg 4 d.jpg 5 e.jpg and so on
select cp1.img_id,cp2.img_id from photos as cp1 cross join photos as cp2 limit ?,1
How I get 15824293949?
I have 177901 rows in my photo table. I can get the total # of possible combinations by using
(total # of rows * total # of rows ) – total # of rows)/2
Try limiting the query with a
WHEREclause on a column with an index on it. E.g.:Update: I think perhaps you don’t even need the database? You can find the nth combination of two images by calculating something like
15824293949 / 177901and15824293949 % 177901. I suppose you could write a query:If you’re trying to get them from the natural order that they’re in the database (and it doesn’t happen to be their img_id) then you might have some trouble. Does it matter? It’s not clear what you’re trying to do here.