title: How to speed up table-retrieval with MATLAB and JDBC?
body: <p>I am accessing a PostGreSQL 8.4 database with JDBC called by MATLAB.
  The tables I am interested in basically consist of various columns of different datatypes. They are selected through their time-stamps.</p>
  
  <p>Since I want to retrieve big amounts of data I am looking for a way of making the request faster than it is right now.</p>
  
  <hr>
  
  <p>What I am doing at the moment is the following:
  First I establish a connection to the database and call it <code>DBConn</code>. Next step would be to prepare a Select-Statement and execute it:
  </p>
  
  <pre><code>QUERYSTRING = ['SELECT * FROM ' TABLENAME '...
  WHERE ts BETWEEN ''' TIMESTART ''' AND ''' TIMEEND ''''];
  
  QUERY = DBConn.prepareStatement(QUERYSTRING);
  RESULTSET = QUERY.executeQuery();
  </code></pre>
  
  <p>Then I store the columntypes in variable COLTYPE (1 for <code>FLOAT</code>, -1 for <code>BOOLEAN</code> and 0 for the rest - nearly all columns contain <code>FLOAT</code>). Next step is to process every row, column by column, and retrieve the data by the corresponding methods. <code>FNAMES</code> contains the fieldnames of the table.</p>
  
  <pre><code>m=0; % Variable containing rownumber
  
  while RESULTSET.next()
    m = m+1;
  
    for n = 1:length(FNAMES)
  
      if COLTYPE(n)==1 % Columntype is a FLOAT
        DATA{1}.(FNAMES{n})(m,1) = RESULTSET.getDouble(n);
      elseif COLTYPE(n)==-1 % Columntype is a BOOLEAN
        DATA{1}.(FNAMES{n})(m,1) = RESULTSET.getBoolean(n);
      else
        DATA{1}.(FNAMES{n}){m,1} = char(RESULTSET.getString(n));
      end
  
    end
  
  end
  </code></pre>
  
  <p>When I am done with my request I close the statement and the connection.</p>
  
  <p>I don´t have the MATLAB database toolbox so I am looking for solutions without it.</p>
  
  <hr>
  
  <p>I understand that it is very ineffective to request the data of every single field. Still, I failed on finding a way to get more data at once - for example multiple rows of the same column. Is there any way to do so? Do you have other suggestions of speeding the request up?</p>