Hi,

Sorry I can't reproduce this, it took about 1.6 seconds in my test
case (see below). In any case, there is a faster way: use the Csv tool
directly. When using a SELECT statement, the result set is buffered to
a file, which is slow. Try:

ResultSet rs = Csv.getInstance().read("datafile.csv", null, null);

See also the CsvSample class in the samples section. My test case:
    public static void main(String[] args) throws Exception {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection(
        "jdbc:h2:data/test", "sa", "sa");
Statement stat=conn.createStatement();
long time=System.currentTimeMillis();
stat.execute("call csvwrite('data/test.csv', 'select x, space(100) "+
        "from system_range(1, 50000)')");
System.out.println("write: "+(System.currentTimeMillis()-time));
time=System.currentTimeMillis();
ResultSet rs=stat.executeQuery(
        "call csvread('data/test.csv')");
System.out.println("select: "+(System.currentTimeMillis()-time));
while (rs.next()) {
    // ignore
}
System.out.println(" loop: "+(System.currentTimeMillis()-time));
time=System.currentTimeMillis();
rs=Csv.getInstance().read("data/test.csv", null, null);
System.out.println("read: "+(System.currentTimeMillis()-time));
while (rs.next()) {
    // ignore
}
System.out.println(" loop: "+(System.currentTimeMillis()-time));
conn.close();

Result (times in milliseconds):
write: 2250
select: 1219
 loop: 1610
read: 0
 loop: 484

Regards,
Thomas



On Wed, Nov 5, 2008 at 3:52 PM, lucky001 <[EMAIL PROTECTED]> wrote:
>
> Hi everyone
>
> I am using CSVREAD to read data from CSV file.
>
> I am working with a device that has only 64 MB of RAM. I have about
> 50,000 records in that flat data (CSV) file and each record is around
> 100 bytes.
>
> Probelm is it is taking around 3 minutes to select one record.
> ============================================
>
> Here is the statement I am using in my program.
>
> sql = "SELECT * FROM CSVREAD('datafile.csv')";
> rs = stmt.executeQuery(sql);;
>
> Any clues?
>
>
>
> Sohail
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to