mysql - Selecting every row in a table without using limit? -


i'm using jdbc mysql. need iterate on every row in table (60,000 rows, table = innodb), , perform processing on each.

will mysql accept query without limit that? in simplest implementation, select entire table, , keep iterating results while cursor gives me more results:

preparedstatement stmt = conn.preparestatement("select * foo"); resultset rs = stmt.getresultset(); while (rs.next()) {     .. stuff on each row .. } 

i can implement paging query of course in batches, it'd simpler stated in first approach. wonder if mysql internally, or tries load entire query result set memory first?

thanks

mysql gonna run , try best sure, or @ least try use our memory until runs out. it's interesting highlight in few other points:

  1. even using limit, mysql parser still gonna fullscan in table. limit runs in 1 level after process;
  2. mysql gonna try use memory , if not enough, parser swaps filesystem, more slower , expensive in terms of performance;
  3. try use indexes , clause make of queries. surely don't need bring application layer;

good luck!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -