Re: Memory exeception

From: Barry Lind <barry(at)xythos(dot)com>
To: nickf(at)ontko(dot)com
Cc: Peter Wasem <peter(dot)wasem(at)itag(dot)ch>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Memory exeception
Date: 2001-11-08 17:46:31
Message-ID: 3BEAC4F7.1020907@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Nick,

If by 'this approach' you mean using explicit cursors and fetch
statements, the answer is yes. The query in the cursor is run in the
same way as without a cursor. Each fetch statement allows you to get an
additional set of rows. There is also a MOVE statement that lets you
move to a specific row in the query to return it, also fetch allows you
to fetch backwards or forwards through the cursor. You can think of
cursors as simply having the result set maintained on the server instead
of the client. Fetch and move allow you to access the rows.

thanks,
--Barry

Nick Fankhauser wrote:

> Is it possible to take this approach with a query that has an "order by" in
> it?
>
> -Nick
>
>
>>-----Original Message-----
>>
>
>>Hi Barry
>>
>>This is exactly what I observed. The physical memory dropped down
>>to almost
>>zero (but no swap was used) before the exception was thrown. I'm
>>not sure if I
>>can use cursors (other than ResultSet) since my application is Java-based.
>>
>>Thanks
>>
>>Barry Lind wrote:
>>
>>
>>>Peter,
>>>
>>>Postgres will return the entire result into memory first before
>>>processing the first row of data. If you don't want this behavior you
>>>should use explicit cursors and fetch statements to get data a few rows
>>>at a time. See the postgres documentation on the 'cursor' and 'fetch'
>>>sql statements.
>>>
>>>thanks,
>>>--Barry
>>>
>>>Peter Wasem wrote:
>>>
>>>
>>>>Hi
>>>>
>>>>I have a problem in processing large numbers of rows in ResultSets.
>>>>Here's the code fragment where the problem occurs:
>>>>
>>>>...
>>>> ResultSet rset = stmt.executeQuery( "select ... from ... where ...
>>>>order by ..." ) ;
>>>> while(rset.next() )
>>>> { // Process the row }
>>>>...
>>>>
>>>>The query addresses some 100'000 rows. When stmt.executeQuery() is
>>>>executed suddenly an exception occurs.
>>>>The same program works fine with other JDBC drivers.
>>>>
>>>>Any ideas ?
>>>>
>>>>Greetings
>>>>Peter
>>>>
>>>>---------------------------(end of
>>>>
>>broadcast)---------------------------
>>
>>>>TIP 2: you can get off all lists at once with the unregister command
>>>> (send "unregister YourEmailAddressHere" to
>>>>
>>majordomo(at)postgresql(dot)org)
>>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ned Wolpert 2001-11-08 17:59:08 Re: [HACKERS] MD5-based passwords
Previous Message Ned Wolpert 2001-11-08 17:38:21 Re: Constant "JTable" update